forked from vpnhood/VpnHood
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PublishNuget.ps1
32 lines (27 loc) · 1.25 KB
/
PublishNuget.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
param([Parameter(Mandatory=$true)] [String]$projectDir)
. "$PSScriptRoot\Common.ps1"
# paths
$projectFile = (Get-ChildItem -path $projectDir -file -Filter "*.csproj").FullName;
$assemblyName = ([Xml] (Get-Content $projectFile)).Project.PropertyGroup.AssemblyName;
$packageId = ([Xml] (Get-Content $projectFile)).Project.PropertyGroup.PackageId;
$packageId = "$packageId".Trim();
$publishDir = Join-Path $projectDir "bin\release\publish";
#update project version
UpdateProjectVersion $projectFile;
# packing
Write-Host
Write-Host "*** Packing..." -BackgroundColor Blue
rm "$publishDir" -ErrorAction Ignore -Recurse
dotnet pack "$projectDir" -c "Release" -o "$publishDir" --runtime any -p:Version=$versionParam -p:IncludeSymbols=true -p:SymbolPackageFormat=snupkg
if ($LASTEXITCODE -gt 0) { Throw "The pack exited with error code: " + $lastexitcode; }
# publish nuget
if (!$noPushNuget)
{
Write-Host
Write-Host "*** Publishing..." -BackgroundColor Blue
$packageFile = (Join-Path $publishDir "$packageId.$versionParam.nupkg")
dotnet nuget push $packageFile --api-key $nugetApiKey --source https://api.nuget.org/v3/index.json
if ($LASTEXITCODE -gt 0) { Write-Host ("The publish exited with error code: " + $lastexitcode) -ForegroundColor Red; }
}
# ReportVersion
ReportVersion