1 | @ECHO OFF
|
---|
2 |
|
---|
3 | SET /A COUNT=0
|
---|
4 | FOR /F "tokens=*" %%A IN ('dir /B *.sln') DO (
|
---|
5 | CALL :forloopbody "%%A")
|
---|
6 |
|
---|
7 | IF "%COUNT%"=="1" (
|
---|
8 | SET SELECTED=%SOLUTIONS.1%
|
---|
9 | ECHO Building %SOLUTIONS.1% as it is the only solution that was found ...
|
---|
10 | GOTO :config_platform_selection)
|
---|
11 |
|
---|
12 | ECHO Found the following solutions:
|
---|
13 | FOR /F "tokens=2* delims=.=" %%A IN ('SET SOLUTIONS.') DO ECHO %%A = %%B
|
---|
14 | ECHO.
|
---|
15 | SET /P SOLUTIONINDEX=Which solution to build (type the number):
|
---|
16 |
|
---|
17 | SET SELECTED=""
|
---|
18 | FOR /F "tokens=2* delims=.=" %%A IN ('SET SOLUTIONS.') DO (
|
---|
19 | IF "%%A"=="%SOLUTIONINDEX%" SET SELECTED=%%B)
|
---|
20 |
|
---|
21 | IF %SELECTED%=="" GOTO :eof
|
---|
22 |
|
---|
23 | :config_platform_selection
|
---|
24 | SET /P CONFIGURATION=Which configuration to build [Debug]:
|
---|
25 | IF "%CONFIGURATION%"=="" SET CONFIGURATION=Debug
|
---|
26 | SET /P PLATFORM=Which platform to build [Any CPU]:
|
---|
27 | IF "%PLATFORM%"=="" SET PLATFORM=Any CPU
|
---|
28 |
|
---|
29 | REM First find the path to the msbuild.exe by performing a registry query
|
---|
30 | FOR /F "tokens=1,3 delims= " %%A IN ('REG QUERY "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\4.0"') DO (
|
---|
31 | IF "%%A"=="MSBuildToolsPath" SET MSBUILDPATH=%%B)
|
---|
32 |
|
---|
33 | REM Then execute msbuild to clean and build the solution
|
---|
34 | REM Disable that msbuild creates a cache file of the solution
|
---|
35 | SET MSBuildUseNoSolutionCache=1
|
---|
36 | REM Run msbuild to clean and then build
|
---|
37 | %MSBUILDPATH%msbuild.exe %SELECTED% /target:Clean /p:Configuration="%CONFIGURATION%",Platform="%PLATFORM%" /nologo
|
---|
38 | %MSBUILDPATH%msbuild.exe %SELECTED% /target:Build /p:Configuration="%CONFIGURATION%",Platform="%PLATFORM%" /nologo
|
---|
39 |
|
---|
40 | PAUSE
|
---|
41 |
|
---|
42 | GOTO :eof
|
---|
43 |
|
---|
44 | REM This workaround is necessary so that COUNT gets reevaluated
|
---|
45 | :forloopbody
|
---|
46 | SET /A COUNT+=1
|
---|
47 | SET SOLUTIONS.%COUNT%=%1
|
---|
48 | GOTO :eof |
---|