Enable retries for the nuget push command used during publishing (dotnet/core-setup...
authorchcosta <chcosta@microsoft.com>
Fri, 4 Aug 2017 21:58:30 +0000 (14:58 -0700)
committerGitHub <noreply@github.com>
Fri, 4 Aug 2017 21:58:30 +0000 (14:58 -0700)
* Enable retries for the nuget push command used during publishing

* Alphabetize usingtask list in publish.proj

Commit migrated from https://github.com/dotnet/core-setup/commit/14627e34be86271759ffdd5ea8692a51e2b7f4fe

src/installer/BuildToolsVersion.txt
src/installer/publish/dir.props
src/installer/publish/publish.proj

index 6314566..1f8c009 100644 (file)
@@ -1 +1 @@
-2.0.0-prerelease-01805-01
+2.0.0-prerelease-01903-01
index 0c2b287..0b3bddf 100644 (file)
     <ProductMoniker>$(DistroRid).$(SharedFrameworkNugetVersion)</ProductMoniker>
     <HostResolverVersionMoniker>$(DistroRid).$(HostResolverVersion)</HostResolverVersionMoniker>
   </PropertyGroup>
+
+  <ItemGroup>
+    <!-- IgnorableErrorMessages applies to the "ExectWithRetriesForNuGetPush" task.
+          There's a very special failure scenario that we want to ignore.  That scenario is
+          when NuGet hits a timeout on one "push" attempt, and then gets a "Forbidden" response
+          because the package "already exists" on the next response.  This indicates that the
+          timeout occurred, but the push was actually successful.
+    -->
+    <IgnorableErrorMessages Include="Overwriting existing packages is forbidden according to the package retention settings for this feed.">
+      <ConditionalErrorMessage>Pushing took too long</ConditionalErrorMessage>
+    </IgnorableErrorMessages>
+  </ItemGroup>
   
   <ItemGroup>
     <CompressedFile Include="$(PackagesOutDir)**/*$(CompressedFileExtension)">
index f0b7889..24de5dc 100644 (file)
@@ -2,6 +2,7 @@
 <Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
   <UsingTask TaskName="DownloadFromAzure" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll" />
+  <UsingTask TaskName="ExecWithRetriesForNuGetPush" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll" />
   <UsingTask TaskName="FinalizeBuild" AssemblyFile="$(LocalBuildToolsTaskDir)core-setup.tasks.dll" />
   <UsingTask TaskName="ListAzureBlobs" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll" />
   <UsingTask TaskName="UploadToAzure" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.CloudTestTasks.dll" />
       <NuGetPushSymbolsCommand>$(DotnetToolCommand) nuget push --source $(NuGetSymbolsFeedUrl) --api-key $(NuGetApiKey) --timeout $(NuGetPushTimeoutSeconds)</NuGetPushSymbolsCommand>
     </PropertyGroup>
 
-      <!-- ToDo: look at moving this to an msbuild task so that we can include retry logic, parallelize it, and hide the api key -->
-    <Exec Command="$(NuGetPushCommand) %(_DownloadedStandardPackages.Identity)" />
+    <ExecWithRetriesForNuGetPush Command="$(NuGetPushCommand) %(_DownloadedStandardPackages.Identity)"
+                                 IgnoredErrorMessagesWithConditional="@(IgnorableErrorMessages)" />
 
     <Message Condition="'@(_DownloadedSymbolsPackages)' != ''" Text="Pushing CoreHost symbols packages to $(NuGetSymbolsFeedUrl)" />
-    <Exec Condition="'@(_DownloadedSymbolsPackages)' != ''" Command="$(NuGetPushSymbolsCommand) %(_DownloadedSymbolsPackages.Identity)" />
+    <ExecWithRetriesForNuGetPush Condition="'@(_DownloadedSymbolsPackages)' != ''"
+                                 Command="$(NuGetPushSymbolsCommand) %(_DownloadedSymbolsPackages.Identity)"
+                                 IgnoredErrorMessagesWithConditional="@(IgnorableErrorMessages)" />
   </Target>
 
   <Target Name="PublishDebToolPackageToFeed"
     <PropertyGroup>
       <NuGetPushCommand>$(DotnetToolCommand) nuget push --source $(CliNuGetFeedUrl) --api-key $(CliNuGetApiKey) --timeout $(NuGetPushTimeoutSeconds)</NuGetPushCommand>
     </PropertyGroup>
-    <Exec Command="$(NuGetPushCommand) %(DebToolPackages.Identity)" />
+    <ExecWithRetriesForNuGetPush Command="$(NuGetPushCommand) %(DebToolPackages.Identity)"
+                                 IgnoredErrorMessagesWithConditional="@(IgnorableErrorMessages)" />
   </Target>
   
   <Import Project="$(ToolsDir)VersionTools.targets" Condition="Exists('$(ToolsDir)VersionTools.targets')" />