Created
August 7, 2015 01:45
-
-
Save FeodorFitsner/508b71250295590e6408 to your computer and use it in GitHub Desktop.
Batch file to reliably restore nuget packages with retries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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