File tree 1 file changed +27
-4
lines changed
1 file changed +27
-4
lines changed Original file line number Diff line number Diff line change @@ -145,11 +145,34 @@ function UpdateNuspec($nuspecPath, $language) {
145
145
146
146
function RestorePkgs ($sln ) {
147
147
Write-Host " Restoring $sln ..." - ForegroundColor Green
148
- if ( -Not ( Test-Path $sln )) {
149
- Write-Host " File $sln does not exist, exiting. " - ForegroundColor DarkRed
150
- return
148
+ Retry {
149
+ . $nugetExe restore $sln
150
+ if ( $LASTEXITCODE ) { throw " Nuget restore for $sln failed. " }
151
151
}
152
- exec { . $nugetExe restore $sln }
152
+ }
153
+
154
+ function Retry {
155
+ Param (
156
+ [parameter (Position = 0 , Mandatory = 1 )]
157
+ [ScriptBlock ]$cmd ,
158
+ [parameter (Position = 1 , Mandatory = 0 )]
159
+ [int ]$times = 3
160
+ )
161
+ $retrycount = 0
162
+ while ($retrycount -lt $times ){
163
+ try {
164
+ & $cmd
165
+ if (! $? ) {
166
+ throw " Command failed."
167
+ }
168
+ return
169
+ }
170
+ catch {
171
+ Write-Host - ForegroundColor Red " Failed: ($ ( $_.Exception.Message ) ), retrying."
172
+ }
173
+ $retrycount ++
174
+ }
175
+ throw " Command '$ ( $cmd.ToString ()) ' failed."
153
176
}
154
177
155
178
function TestPath ($paths ) {
You can’t perform that action at this time.
0 commit comments