Skip to content

Instantly share code, notes, and snippets.

@FeodorFitsner
Created August 7, 2015 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save FeodorFitsner/508b71250295590e6408 to your computer and use it in GitHub Desktop.
Save FeodorFitsner/508b71250295590e6408 to your computer and use it in GitHub Desktop.
Batch file to reliably restore nuget packages with retries
@echo off
rem initiate the retry number
set errorCode=1
set retryNumber=0
set maxRetries=3
:RESTORE
nuget restore %*
rem problem?
IF ERRORLEVEL %errorCode% GOTO :RETRY
rem everything is fine!
GOTO :EXIT
:RETRY
@echo Oops, nuget restore exited with code %errorCode% - let us try again!
set /a retryNumber=%retryNumber%+1
IF %reTryNumber% LSS %maxRetries% (GOTO :RESTORE)
IF %retryNumber% EQU %maxRetries% (GOTO :ERR)
:ERR
@echo Sorry, we tried restoring nuget packages for %maxRetries% times and all attempts were unsuccessful!
EXIT /B 1
:EXIT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment