Skip to content

Commit 845563e

Browse files
committed
Don't publish to NuGet if the version has already been published
1 parent 25869d1 commit 845563e

3 files changed

Lines changed: 22 additions & 19 deletions

File tree

build/appveyor-deploy-docs.ps1

Lines changed: 0 additions & 17 deletions
This file was deleted.

build/build.proj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,16 @@
7474
<Exec Command="$(NuGet) pack ..\src\corelib\corelib.nuspec -OutputDirectory ..\artifacts\packages -Prop Configuration=$(Configuration) -Version $(Version) -Symbols" />
7575
</Target>
7676

77-
<Target Name="Publish" DependsOnTargets="DownloadNuGet">
77+
<Target Name="PublishNuGet" DependsOnTargets="DownloadNuGet">
78+
<Exec Command="@powershell -NoProfile -ExecutionPolicy unrestricted -File check-nuget-version-exists.ps1 $(Version)" ConsoleToMSBuild="true">
79+
<Output TaskParameter="ConsoleOutput" PropertyName="ShouldPublishToNuGet" />
80+
</Exec>
81+
7882
<!-- The environment variable BAMBOO_NUGET_PASSWORD comes from the nuget.password variable defined on the openstack.net plan in Bamboo -->
79-
<Exec Command="$(NuGet) push ..\artifacts\packages\openstack.net.$(Version).nupkg %25BAMBOO_NUGET_PASSWORD%25" />
83+
<Message Text="Skipping publish to NuGet because version $(Version) has already been published."
84+
Condition=" '$(ShouldPublishToNuGet)' == 'False' " />
85+
<Exec Command="$(NuGet) push ..\artifacts\packages\openstack.net.$(Version).nupkg %25BAMBOO_NUGET_PASSWORD%25"
86+
Condition=" '$(ShouldPublishToNuGet)' == 'True' " />
8087
</Target>
8188

8289
</Project>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
param (
2+
[string]$version
3+
)
4+
5+
try {
6+
$url = "http://nuget.org/packages/openstack.net/$version"
7+
$status = (Invoke-WebRequest $url).StatusCode
8+
} catch {
9+
$status = $_.Exception.Response.StatusCode.Value__
10+
}
11+
12+
$shouldPublishToNuGet = $status -eq '404'
13+
Write-Host $shouldPublishToNuGet

0 commit comments

Comments
 (0)