diff --git a/build.cake b/build.cake index 32d4193706f88ed48d24c3db639e3915d307c9db..fbfb318e3ced9d523193d98b3b7c783b32dac606 100644 --- a/build.cake +++ b/build.cake @@ -296,16 +296,21 @@ Task("NugetPush") .Does(() =>{ var nupkgs = GetFiles($"{nupkgDir}/*.nupkg"); Information("Need to push {0} packages", nupkgs.Count); - foreach(var nupkg in nupkgs) { - Information("Pushing {0}", nupkg); - NuGetPush(nupkg, new NuGetPushSettings { - Source = nugetSource, - ApiKey = nugetApiKey - }); + if(!String.IsNullOrWhiteSpace(nugetApiKey)) { + foreach(var nupkg in nupkgs) { + Information("Pushing {0}", nupkg); + NuGetPush(nupkg, new NuGetPushSettings { + Source = nugetSource, + ApiKey = nugetApiKey + }); + } + } else { + Information("NugetApiKey is not set. Can't push."); + throw new Exception("NugetApiKey is not set. Can't push."); } }); -Task("MoveToArtifacts") +Task("CopyToArtifacts") .Does(() =>{ foreach(var project in projects) { if(!project.GetDirectory().ToString().EndsWith(".Tests") @@ -320,11 +325,12 @@ Task("MoveToArtifacts") Task("Prerelease") .IsDependentOn("Build") -.IsDependentOn("MoveToArtifacts"); +.IsDependentOn("CopyToArtifacts"); Task("Release") -.IsDependentOn("NugetPush") -.IsDependentOn("MoveToArtifacts"); +.IsDependentOn("NugetPack") +.IsDependentOn("CopyToArtifacts") +.IsDependentOn("NugetPush"); Task("Default") .IsDependentOn("Test");