Retry restore on failure (#7544)

* switch to using a retry
This commit is contained in:
Travis Plunk 2018-08-16 14:23:30 -07:00 committed by Aditya Patwardhan
parent 0a1a47e8b0
commit 01634e4b2e

View file

@ -695,7 +695,26 @@ function Restore-PSPackage
$ProjectDirs | ForEach-Object {
Write-Log "Run dotnet restore $_ $RestoreArguments"
Start-NativeExecution { dotnet restore $_ $RestoreArguments }
$retryCount = 0
$maxTries = 5
while($retryCount -lt $maxTries)
{
try
{
Start-NativeExecution { dotnet restore $_ $RestoreArguments }
}
catch
{
Write-Log "Failed to restore $_, retrying..."
$retryCount++
if($retryCount -ge $maxTries)
{
throw
}
}
break
}
}
}
}