Skip to content

Commit

Permalink
close #3954 - properly push .snupkg files to NuGet feed (#4176)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaronontheweb authored Jan 29, 2020
1 parent d185948 commit 3517103
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions build.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@ Target "CreateMntrNuget" (fun _ ->

Target "PublishNuget" (fun _ ->
let nugetExe = FullName @"./tools/nuget.exe"
let rec publishPackage url accessKey trialsLeft packageFile =
let rec publishPackage url apiKey trialsLeft packageFile =
let tracing = enableProcessTracing
enableProcessTracing <- false
let args p =
Expand All @@ -481,19 +481,17 @@ Target "PublishNuget" (fun _ ->

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))
DotNetCli.RunCommand
(fun p ->
{ p with
TimeOut = TimeSpan.FromMinutes 10. })
(sprintf "nuget push %s --api-key %s --source %s" packageFile apiKey url)
with exn ->
if (trialsLeft > 0) then (publishPackage url accessKey (trialsLeft-1) packageFile)
if (trialsLeft > 0) then (publishPackage url apiKey (trialsLeft-1) packageFile)
else raise exn
let shouldPushNugetPackages = hasBuildParam "nugetkey"
let shouldPushSymbolsPackages = (hasBuildParam "symbolspublishurl") && (hasBuildParam "symbolskey")

if (shouldPushNugetPackages || shouldPushSymbolsPackages) then
if (shouldPushNugetPackages) then
printfn "Pushing nuget packages"
if shouldPushNugetPackages then
let normalPackages= !! (outputNuGet @@ "*.nupkg") |> Seq.sortBy(fun x -> x.ToLower())
Expand All @@ -502,14 +500,6 @@ Target "PublishNuget" (fun _ ->
publishPackage (getBuildParamOrDefault "nugetpublishurl" "https://api.nuget.org/v3/index.json") (getBuildParam "nugetkey") 3 package
with exn ->
printfn "%s" exn.Message

if shouldPushSymbolsPackages then
let symbolPackages= !! (outputNuGet @@ "*.snupkg") |> Seq.sortBy(fun x -> x.ToLower())
for package in symbolPackages do
try
publishPackage (getBuildParam "symbolspublishurl") (getBuildParam "symbolskey") 3 package
with exn ->
printfn "%s" exn.Message
)

//--------------------------------------------------------------------------------
Expand Down

0 comments on commit 3517103

Please sign in to comment.