-
Notifications
You must be signed in to change notification settings - Fork 1
/
pack.ps1
52 lines (44 loc) · 1.42 KB
/
pack.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# Paths
$packFolder = (Get-Item -Path "./" -Verbose).FullName
$slnPath = $packFolder
$srcPath = Join-Path $slnPath "src"
# List of projects
$projects = (
"Creekdream.Cache.Core",
"Creekdream.Cache.Redis",
"Creekdream.Cache.Memory"
)
# Rebuild solution
Set-Location $slnPath
& dotnet restore
# Copy all nuget packages to the pack folder
foreach($project in $projects) {
$projectFolder = Join-Path $srcPath $project
# Create nuget pack
Set-Location $projectFolder
$projectBinFolder = Join-Path $projectFolder "bin/Release"
$isExistsBinFolder = Test-Path $projectBinFolder
if($isExistsBinFolder -eq $True){
Remove-Item -Recurse $projectBinFolder
}
& dotnet msbuild /p:Configuration=Release /p:SourceLinkCreate=true
& dotnet msbuild /t:pack /p:Configuration=Release /p:SourceLinkCreate=true
# Copy nuget package
$projectPackPath = Join-Path $projectBinFolder ($project + ".*.nupkg")
Move-Item $projectPackPath $packFolder
}
# Go back to the pack folder
Set-Location $packFolder
Write-Host ""
Write-Host "Do you wish to post to microsoft nuget ?"
Write-Host ""
$isPublish = Read-Host 'Please enter y or n ?'
if ($isPublish -eq 'y') {
$nugetAppId = Read-Host 'Please enter your nuget appid'
foreach ($packfile in Get-ChildItem -Path $packFolder -Recurse -Include *.nupkg) {
tools\nuget\nuget.exe push $packfile -Source https://www.nuget.org/api/v2/package $nugetAppId
}
}
del *.nupkg
pause
exit