From 80dbfee26736e4bb107df2538821c89a7519e7df Mon Sep 17 00:00:00 2001 From: Mark Heath Date: Tue, 10 May 2022 14:01:43 +0100 Subject: [PATCH] updated publish to NuGet script --- publish.ps1 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/publish.ps1 b/publish.ps1 index d7134f0..2c0ca8b 100644 --- a/publish.ps1 +++ b/publish.ps1 @@ -1,5 +1,12 @@ # publishes to NuGet # $apiKey needs to be already set up with NuGet publishing key +Write-Host $PSScriptRoot + +if (-not $apiKey) +{ + throw "Need to set the API key first" +} + $packages = "NAudio.Core", "NAudio.Asio", "NAudio.WinForms", "NAudio.Midi", "NAudio.WinMM", "NAudio.Wasapi", "NAudio.Uap", "NAudio", "NAudio.Extras" @@ -7,9 +14,11 @@ $packages = "NAudio.Core", "NAudio.Asio", "NAudio.WinForms", "NAudio.Midi", foreach ($package in $packages) { # publish the most recently created .nupkg file - $folder = "$package\bin\Release" + $folder = "$PSScriptRoot\$package\bin\Release" $recent = gci "$folder\*.nupkg" | sort LastWriteTime | select -last 1 $pkg = $recent.Name # note that this will fail with 409 error if you try to push package that already exists - dotnet nuget push "$folder\$pkg" --api-key $apiKey --source https://api.nuget.org/v3/index.json + Write-Host "publishing $pkg" + dotnet nuget push "$folder\$pkg" --api-key $apiKey --source https://api.nuget.org/v3/index.json | out-null + if (-not $?) { Write-Error "Failed to publish $pkg" } } \ No newline at end of file