Skip to content

Commit

Permalink
Add restore with retry in Nuke build (#841)
Browse files Browse the repository at this point in the history
* Update build.ps1

* Update build.ps1
  • Loading branch information
pellared authored Jun 14, 2022
1 parent 950e89b commit 867af40
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,18 @@ $env:DOTNET_MULTILEVEL_LOOKUP = 0
# EXECUTION
###########################################################################

function ExecSafe([scriptblock] $cmd) {
& $cmd
if ($LASTEXITCODE) { exit $LASTEXITCODE }
function ExecSafe([scriptblock] $cmd, [int]$maxRetries = 0) {
$tryCount = 0
while ($true) {
$tryCount++
& $cmd
if ($global:LASTEXITCODE -eq 0) {
break
}
if ($tryCount -gt $maxRetries) {
exit $global:LASTEXITCODE
}
}
}

# If dotnet CLI is installed globally and it matches requested version, use for execution
Expand Down Expand Up @@ -65,5 +74,6 @@ else {

Write-Output "Microsoft (R) .NET Core SDK version $(& $env:DOTNET_EXE --version)"

ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet }
ExecSafe { & $env:DOTNET_EXE restore $BuildProjectFile -nologo -clp:NoSummary --verbosity quiet } -maxRetries 2
ExecSafe { & $env:DOTNET_EXE build $BuildProjectFile /nodeReuse:false /p:UseSharedCompilation=false -nologo -clp:NoSummary --verbosity quiet --no-restore }
ExecSafe { & $env:DOTNET_EXE run --project $BuildProjectFile --no-build -- $BuildArguments }

0 comments on commit 867af40

Please sign in to comment.