[4863] | 1 | @ECHO OFF
|
---|
| 2 |
|
---|
[7215] | 3 | SET CLEANBEFOREBUILD=0
|
---|
[4919] | 4 |
|
---|
| 5 | SET SELECTED=
|
---|
| 6 | SET CONFIGURATION=
|
---|
| 7 | SET PLATFORM=
|
---|
| 8 |
|
---|
| 9 | IF "%~1"=="" GOTO :prompt_solution
|
---|
| 10 |
|
---|
| 11 | SET SELECTED=%1
|
---|
| 12 | IF NOT EXIST %SELECTED% (
|
---|
| 13 | ECHO Solution file %SELECTED% could not be found.
|
---|
| 14 | GOTO :end
|
---|
| 15 | )
|
---|
| 16 | ECHO Building solution %SELECTED% ...
|
---|
| 17 | GOTO :config_selection
|
---|
| 18 |
|
---|
| 19 | :prompt_solution
|
---|
[4863] | 20 | SET /A COUNT=0
|
---|
| 21 | FOR /F "tokens=*" %%A IN ('dir /B *.sln') DO (
|
---|
[4919] | 22 | CALL :forloopbody "%%A"
|
---|
| 23 | )
|
---|
[4863] | 24 |
|
---|
[4873] | 25 | IF "%COUNT%"=="1" (
|
---|
| 26 | SET SELECTED=%SOLUTIONS.1%
|
---|
| 27 | ECHO Building %SOLUTIONS.1% as it is the only solution that was found ...
|
---|
[4919] | 28 | GOTO :config_selection
|
---|
| 29 | )
|
---|
[4873] | 30 |
|
---|
[4863] | 31 | ECHO Found the following solutions:
|
---|
| 32 | FOR /F "tokens=2* delims=.=" %%A IN ('SET SOLUTIONS.') DO ECHO %%A = %%B
|
---|
| 33 | ECHO.
|
---|
[4919] | 34 | SET /P SOLUTIONINDEX=Which solution to build? Type the number:
|
---|
[4863] | 35 |
|
---|
| 36 | SET SELECTED=""
|
---|
| 37 | FOR /F "tokens=2* delims=.=" %%A IN ('SET SOLUTIONS.') DO (
|
---|
[4919] | 38 | IF "%%A"=="%SOLUTIONINDEX%" SET SELECTED=%%B
|
---|
| 39 | )
|
---|
[4863] | 40 |
|
---|
| 41 | IF %SELECTED%=="" GOTO :eof
|
---|
| 42 |
|
---|
[4919] | 43 | :config_selection
|
---|
| 44 | IF "%~2"=="" GOTO :prompt_config
|
---|
| 45 |
|
---|
| 46 | SET CONFIGURATION=%~2
|
---|
| 47 | ECHO Building configuration %CONFIGURATION% ...
|
---|
| 48 | GOTO :platform_selection
|
---|
| 49 |
|
---|
| 50 | :prompt_config
|
---|
[7215] | 51 | SET /P CONFIGURATION=Which configuration to build [Release]:
|
---|
| 52 | IF "%CONFIGURATION%"=="" SET CONFIGURATION=Release
|
---|
[4919] | 53 |
|
---|
| 54 | :platform_selection
|
---|
| 55 | IF "%~3"=="" GOTO :prompt_platform
|
---|
| 56 |
|
---|
| 57 | SET PLATFORM=%~3
|
---|
| 58 | ECHO Building platform %PLATFORM% ...
|
---|
| 59 | GOTO :main
|
---|
| 60 |
|
---|
| 61 | :prompt_platform
|
---|
[4863] | 62 | SET /P PLATFORM=Which platform to build [Any CPU]:
|
---|
| 63 | IF "%PLATFORM%"=="" SET PLATFORM=Any CPU
|
---|
| 64 |
|
---|
[4919] | 65 | :main
|
---|
[4863] | 66 | REM First find the path to the msbuild.exe by performing a registry query
|
---|
[4873] | 67 | FOR /F "tokens=1,3 delims= " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0"') DO (
|
---|
| 68 | IF "%%A"=="MSBuildToolsPath" SET MSBUILDPATH=%%B)
|
---|
[4863] | 69 |
|
---|
| 70 | REM Then execute msbuild to clean and build the solution
|
---|
| 71 | REM Disable that msbuild creates a cache file of the solution
|
---|
| 72 | SET MSBuildUseNoSolutionCache=1
|
---|
| 73 | REM Run msbuild to clean and then build
|
---|
[4919] | 74 | IF "%CLEANBEFOREBUILD%"=="1" (
|
---|
[4922] | 75 | ECHO Cleaning ...
|
---|
[4924] | 76 | %MSBUILDPATH%msbuild.exe %SELECTED% /target:Clean /p:Configuration="%CONFIGURATION%",Platform="%PLATFORM%" /m:2 /nologo /verbosity:q /clp:ErrorsOnly
|
---|
[4919] | 77 | )
|
---|
[4922] | 78 | ECHO Building ...
|
---|
[7215] | 79 | %MSBUILDPATH%msbuild.exe %SELECTED% /target:Rebuild /p:Configuration="%CONFIGURATION%",Platform="%PLATFORM%" /m:2 /nologo /verbosity:q /clp:ErrorsOnly
|
---|
[4863] | 80 |
|
---|
[4922] | 81 | ECHO.
|
---|
| 82 | ECHO DONE.
|
---|
| 83 |
|
---|
[4919] | 84 | :end
|
---|
| 85 |
|
---|
[4863] | 86 | PAUSE
|
---|
| 87 |
|
---|
| 88 | GOTO :eof
|
---|
| 89 |
|
---|
| 90 | REM This workaround is necessary so that COUNT gets reevaluated
|
---|
| 91 | :forloopbody
|
---|
| 92 | SET /A COUNT+=1
|
---|
| 93 | SET SOLUTIONS.%COUNT%=%1
|
---|
[4924] | 94 | GOTO :eof
|
---|