diff --git a/build.psm1 b/build.psm1 index 0fa92ed2ad..57e56a0619 100644 --- a/build.psm1 +++ b/build.psm1 @@ -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 + } } } }