All of our build systems that depend on FAKE have now begun experiencing an error during NuGet push attempts as a result of changes made to NuGet.exe itself.
Sample logs:
Pushing nuget packages
[17:45:42][Step 1/1] Pushing D:\BuildAgent\work\2de53b95e0be9250\bin\nuget\NBench.0.1.0.nupkg Attempts left: 3
[17:45:42][Step 1/1] Pushing NBench 0.1.0 to the NuGet gallery (https://www.nuget.org)...
[17:45:47][Step 1/1] Your package was pushed.
[17:45:47][Step 1/1] Pushing NBench 0.1.0 to the symbol server (https://nuget.smbsrc.net/)...
[17:46:42][Step 1/1] Pushing D:\BuildAgent\work\2de53b95e0be9250\bin\nuget\NBench.0.1.0.nupkg Attempts left: 2
[17:46:42][Step 1/1] Pushing NBench 0.1.0 to the NuGet gallery (https://www.nuget.org)...
[17:46:43][Step 1/1] Failed to process request. 'A package with id 'NBench' and version '0.1.0' already exists and cannot be modified.'.
[17:46:43][Step 1/1] The remote server returned an error: (409) Conflict..
[17:46:43][Step 1/1] Pushing D:\BuildAgent\work\2de53b95e0be9250\bin\nuget\NBench.0.1.0.nupkg Attempts left: 1
[17:46:44][Step 1/1] Pushing NBench 0.1.0 to the NuGet gallery (https://www.nuget.org)...
[17:46:44][Step 1/1] Failed to process request. 'A package with id 'NBench' and version '0.1.0' already exists and cannot be modified.'.
[17:46:44][Step 1/1] The remote server returned an error: (409) Conflict..
[17:46:44][Step 1/1] Pushing D:\BuildAgent\work\2de53b95e0be9250\bin\nuget\NBench.0.1.0.nupkg Attempts left: 0
[17:46:45][Step 1/1] Pushing NBench 0.1.0 to the NuGet gallery (https://www.nuget.org)...
Corresponding code
let publishNugetPackages _ =
let rec publishPackage url accessKey trialsLeft packageFile =
let tracing = enableProcessTracing
enableProcessTracing <- false
let args p =
match p with
| (pack, key, "") -> sprintf "push \"%s\" %s" pack key
| (pack, key, url) -> sprintf "push \"%s\" %s -source %s" pack key url
tracefn "Pushing %s Attempts left: %d" (FullName packageFile) trialsLeft
try
let result = ExecProcess (fun info ->
info.FileName <- nugetExe
info.WorkingDirectory <- (Path.GetDirectoryName (FullName packageFile))
info.Arguments <- args (packageFile, accessKey,url)) (System.TimeSpan.FromMinutes 1.0)
enableProcessTracing <- tracing
if result <> 0 then failwithf "Error during NuGet symbol push. %s %s" nugetExe (args (packageFile, "key omitted",url))
with exn ->
if (trialsLeft > 0) then (publishPackage url accessKey (trialsLeft-1) packageFile)
else raise exn
let shouldPushNugetPackages = hasBuildParam "nugetkey"
let shouldPushSymbolsPackages = (hasBuildParam "symbolspublishurl") && (hasBuildParam "symbolskey")
if (shouldPushNugetPackages || shouldPushSymbolsPackages) then
printfn "Pushing nuget packages"
if shouldPushNugetPackages then
let normalPackages=
!! (nugetDir @@ "*.nupkg")
-- (nugetDir @@ "*.symbols.nupkg") |> Seq.sortBy(fun x -> x.ToLower())
for package in normalPackages do
publishPackage (getBuildParamOrDefault "nugetpublishurl" "") (getBuildParam "nugetkey") 3 package
if shouldPushSymbolsPackages then
let symbolPackages= !! (nugetDir @@ "*.symbols.nupkg") |> Seq.sortBy(fun x -> x.ToLower())
for package in symbolPackages do
publishPackage (getBuildParam "symbolspublishurl") (getBuildParam "symbolskey") 3 package
Issue appears to be that NuGet.exe no longer returns a 0 exit code upon successful publish. What was the reasoning behind this?
Should be noted - this worked fine with all of the 2.x NuGet releases from earlier this year and I have plenty of ways to work around this issue, but what's more annoying is why would NuGet.exe give me back a false negative error code? Makes it very difficult to use it in scripts when it doesn't march to the same drum as everything else.