@@ -154,9 +154,6 @@ function InitializeDotNetCli([bool]$install, [bool]$createSdkLocationFile) {
154154 return $global :_DotNetInstallDir
155155 }
156156
157- # In case of network error, try to log the current IP for reference
158- Try - LogClientIpAddress
159-
160157 # Don't resolve runtime, shared framework, or SDK from other locations to ensure build determinism
161158 $env: DOTNET_MULTILEVEL_LOOKUP = 0
162159
@@ -712,6 +709,8 @@ function MSBuild() {
712709 Write-PipelineSetVariable - Name ' NUGET_PLUGIN_REQUEST_TIMEOUT_IN_SECONDS' - Value ' 20'
713710 }
714711
712+ Enable-Nuget - EnhancedRetry
713+
715714 $toolsetBuildProject = InitializeToolset
716715 $basePath = Split-Path - parent $toolsetBuildProject
717716 $possiblePaths = @ (
@@ -720,6 +719,8 @@ function MSBuild() {
720719 (Join-Path $basePath (Join-Path $buildTool.Framework ' Microsoft.DotNet.Arcade.Sdk.dll' )),
721720 (Join-Path $basePath (Join-Path netcoreapp2.1 ' Microsoft.DotNet.ArcadeLogging.dll' )),
722721 (Join-Path $basePath (Join-Path netcoreapp2.1 ' Microsoft.DotNet.Arcade.Sdk.dll' ))
722+ (Join-Path $basePath (Join-Path netcoreapp3.1 ' Microsoft.DotNet.ArcadeLogging.dll' )),
723+ (Join-Path $basePath (Join-Path netcoreapp3.1 ' Microsoft.DotNet.Arcade.Sdk.dll' ))
723724 )
724725 $selectedPath = $null
725726 foreach ($path in $possiblePaths ) {
@@ -756,6 +757,8 @@ function MSBuild-Core() {
756757 }
757758 }
758759
760+ Enable-Nuget - EnhancedRetry
761+
759762 $buildTool = InitializeBuildTool
760763
761764 $cmdArgs = " $ ( $buildTool.Command ) /m /nologo /clp:Summary /v:$verbosity /nr:$nodeReuse /p:ContinuousIntegrationBuild=$ci "
@@ -896,3 +899,18 @@ function Try-LogClientIpAddress()
896899 Write-Host " Unable to get this machine's effective IP address for logging: $_ "
897900 }
898901}
902+
903+ #
904+ # If $ci flag is set, turn on (and log that we did) special environment variables for improved Nuget client retry logic.
905+ #
906+ function Enable-Nuget-EnhancedRetry () {
907+ if ($ci ) {
908+ Write-Host " Setting NUGET enhanced retry environment variables"
909+ $env: NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY = ' true'
910+ $env: NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT = 6
911+ $env: NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS = 1000
912+ Write-PipelineSetVariable - Name ' NUGET_ENABLE_EXPERIMENTAL_HTTP_RETRY' - Value ' true'
913+ Write-PipelineSetVariable - Name ' NUGET_EXPERIMENTAL_MAX_NETWORK_TRY_COUNT' - Value ' 6'
914+ Write-PipelineSetVariable - Name ' NUGET_EXPERIMENTAL_NETWORK_RETRY_DELAY_MILLISECONDS' - Value ' 1000'
915+ }
916+ }
0 commit comments