Make pushing to NuGet feed more resilient.
This commit is contained in:
parent
8cc1d57ab2
commit
f4794e5c7f
|
|
@ -106,6 +106,7 @@ default Configuration='${E("Configuration")}'
|
||||||
|
|
||||||
#nuget-install target='install' description='Install NuGet packages to local repo'
|
#nuget-install target='install' description='Install NuGet packages to local repo'
|
||||||
kpm-publish sourcePackagesDir='${BUILD_DIR}' targetPackagesDir='${E("PACKAGES_PUBLISH_DIR")}'
|
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")'
|
#xunit-test target='test' if='Directory.Exists("test")'
|
||||||
k-test each='var projectFile in Files.Include("test/**/project.json")'
|
k-test each='var projectFile in Files.Include("test/**/project.json")'
|
||||||
|
|
|
||||||
|
|
@ -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
|
||||||
Loading…
Reference in New Issue