Make pushing to NuGet feed more resilient.

This commit is contained in:
Pranav K 2015-03-26 09:57:04 -07:00
parent 8cc1d57ab2
commit f4794e5c7f
2 changed files with 43 additions and 0 deletions

View File

@ -106,6 +106,7 @@ default Configuration='${E("Configuration")}'
#nuget-install target='install' description='Install NuGet packages to local repo'
kpm-publish sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
nuget-resilient-publish sourcePackagesDir='${BUILD_DIR}' nugetFeed='${E("NUGET_PUBLISH_FEED")}' if='!string.IsNullOrEmpty(E("NUGET_PUBLISH_FEED"))'
#xunit-test target='test' if='Directory.Exists("test")'
k-test each='var projectFile in Files.Include("test/**/project.json")'

View File

@ -0,0 +1,42 @@
use namespace="System.Threading.Tasks"
@{/*
nuget-resilient-publish
Publishes NuGet packages with retries
sourcePackagesDir=''
Required. Path to packages to push
nugetFeed=''
Required. Feed to publish to.
*/}
@{
var packages = Directory.EnumerateFiles(sourcePackagesDir, "*.nupkg")
.Where(p => !p.EndsWith(".symbols.nupkg"))
.ToArray();
Parallel.ForEach(packages, package =>
{
var retries = 0;
var packagePath = Path.Combine(sourcePackagesDir, package);
start:
try
{
NuGetPush (nugetFeed, packagePath, "");
}
catch
{
if (++retries == 3)
{
throw;
}
goto start;
}
});
}
macro name='NuGetPush' source='string' nupkgFile='string' extra='string'
nuget-push