|
| 1 | +@echo off |
| 2 | +setlocal |
| 3 | + |
| 4 | +rem Clear any user set ERRORLEVEL variable: |
| 5 | +set "ERRORLEVEL=" |
| 6 | + |
| 7 | +rem Enable advanced batch file commands: |
| 8 | +verify argument_to_enforce_error 2>nul |
| 9 | +setlocal EnableExtensions |
| 10 | +if ERRORLEVEL 1 ( |
| 11 | + echo=SCRIPT ABORTED: Command extensions not supported. |
| 12 | + exit /b 1 |
| 13 | +) |
| 14 | +verify argument_to_enforce_error 2>nul |
| 15 | +setlocal EnableDelayedExpansion |
| 16 | +if ERRORLEVEL 1 ( |
| 17 | + endlocal rem Undo "setlocal EnableExtensions" |
| 18 | + echo=SCRIPT ABORTED: Delayed expansion not supported. |
| 19 | + exit /b 1 |
| 20 | +) |
| 21 | + |
| 22 | +rem Configure "exit" to terminate subroutines and entire script: |
| 23 | +if not "%SelfWrapped%"=="%~0" ( |
| 24 | + set "SelfWrapped=%~0" |
| 25 | + %ComSpec% /s /c ""%~0" %*" |
| 26 | + endlocal rem Undo "setlocal EnableExtensions" |
| 27 | + endlocal rem Undo "setlocal EnableDelayedExpansion" |
| 28 | + goto :eof |
| 29 | +) |
| 30 | + |
| 31 | +set "SCRIPTPATH=%~dp0" |
| 32 | +set "SCRIPTPATH=%SCRIPTPATH:~0,-1%" |
| 33 | + |
| 34 | +rem Initialize Microsoft build environment: |
| 35 | +set "arch=x86" |
| 36 | +call where msbuild >nul 2>nul |
| 37 | +if ERRORLEVEL 1 ( |
| 38 | + for %%y in ( "2019" "2017" ) do ( |
| 39 | + for %%v in ( "Enterprise" "Professional" "Community" "BuildTools" ) do ( |
| 40 | + if exist "C:\Program Files (x86)\Microsoft Visual Studio\%%y\%%v\VC\Auxiliary\Build\vcvarsall.bat" ( |
| 41 | + call "C:\Program Files (x86)\Microsoft Visual Studio\%%y\%%v\VC\Auxiliary\Build\vcvarsall.bat" ^ |
| 42 | + %arch% |
| 43 | + if ERRORLEVEL 1 ( rem Not working: 'vcvarsall.bat' never returns error code. |
| 44 | + set "EMESSAGE=Microsoft build environment initialization failed (Microsoft Visual Studio %%y)" |
| 45 | + call :ERROR |
| 46 | + ) |
| 47 | + goto :VISUAL_STUDIO_INITIALIZED |
| 48 | + ) |
| 49 | + ) |
| 50 | + ) |
| 51 | + for %%v in ( "14.0" "12.0" "11.0" "10.0" ) do ( |
| 52 | + if exist "C:\Program Files (x86)\Microsoft Visual Studio %%v\VC\vcvarsall.bat" ( |
| 53 | + call "C:\Program Files (x86)\Microsoft Visual Studio %%v\VC\vcvarsall.bat" ^ |
| 54 | + %arch% |
| 55 | + if ERRORLEVEL 1 ( |
| 56 | + set "EMESSAGE=Microsoft build environment initialization failed (Microsoft Visual Studio v%%v)" |
| 57 | + call :ERROR |
| 58 | + ) |
| 59 | + goto :VISUAL_STUDIO_INITIALIZED |
| 60 | + ) |
| 61 | + ) |
| 62 | + set "EMESSAGE=No Microsoft Visual Studio installation found" |
| 63 | + call :ERROR |
| 64 | +) |
| 65 | +:VISUAL_STUDIO_INITIALIZED |
| 66 | + |
| 67 | +rem Cleanup old builds: |
| 68 | +rmdir /S /Q "%SCRIPTPATH%/eFMUContainerManager.CLI/bin" |
| 69 | +rmdir /S /Q "%SCRIPTPATH%/eFMUContainerManager.CLI/obj" |
| 70 | +rmdir /S /Q "%SCRIPTPATH%/eFMUContainerManager.Core/bin" |
| 71 | +rmdir /S /Q "%SCRIPTPATH%/eFMUContainerManager.Core/obj" |
| 72 | +rmdir /S /Q "%SCRIPTPATH%/eFMUContainerManager.Core.Interfaces/bin" |
| 73 | +rmdir /S /Q "%SCRIPTPATH%/eFMUContainerManager.Core.Interfaces/obj" |
| 74 | +rmdir /S /Q "%SCRIPTPATH%/eFMUManifestsAndContainers/bin" |
| 75 | +rmdir /S /Q "%SCRIPTPATH%/eFMUManifestsAndContainers/obj" |
| 76 | +rmdir /S /Q "%SCRIPTPATH%/eFMUMisc/bin" |
| 77 | +rmdir /S /Q "%SCRIPTPATH%/eFMUMisc/obj" |
| 78 | + |
| 79 | +rem Build new release: |
| 80 | +msbuild ^ |
| 81 | + "%SCRIPTPATH%/eFMUContainerManager.sln" ^ |
| 82 | + "/property:Configuration=Release" ^ |
| 83 | + "/property:Platform=Any CPU" |
| 84 | +if ERRORLEVEL 1 ( |
| 85 | + set "EMESSAGE=Build failed with errors" |
| 86 | + call :ERROR |
| 87 | +) |
| 88 | +exit %ERRORLEVEL% |
| 89 | + |
| 90 | +rem ********************************************************************************************************** Support functions: |
| 91 | + |
| 92 | +rem Print error message and exit: |
| 93 | +:ERROR |
| 94 | +echo= |
| 95 | +echo=ERROR: %EMESSAGE%. |
| 96 | +echo= |
| 97 | +exit 1 |
0 commit comments