|
1 | 1 | @echo off
|
| 2 | + |
| 3 | +REM Default VS paths to check if no Paths.cmd file exists |
| 4 | +set VISUAL_STUDIO_PATH_0="%programfiles(x86)%\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\msbuild.exe" |
| 5 | +set VISUAL_STUDIO_PATH_1="%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" |
| 6 | +set VISUAL_STUDIO_PATH_2="%programfiles(x86)%\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\msbuild.exe" |
| 7 | +set VISUAL_STUDIO_PATH_3="%programfiles(x86)%\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\msbuild.exe" |
| 8 | + |
2 | 9 | pushd "%~dp0"
|
3 | 10 | if exist Debug rd /s /q Debug
|
4 | 11 | if exist Release rd /s /q Release
|
5 | 12 | if exist x64 rd /s /q x64
|
6 | 13 |
|
7 |
| -"%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin\msbuild.exe" /p:Configuration=Release |
| 14 | +if exist "Paths.cmd" ( |
| 15 | +REM Prefer Paths.cmd as Visual Studio path source if it exists. |
| 16 | +call Paths.cmd |
| 17 | +goto build |
| 18 | +) else ( |
| 19 | +REM Otherwise try to auto-detect the Visual Studio path. |
| 20 | +if exist %VISUAL_STUDIO_PATH_0% ( |
| 21 | +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_0% |
| 22 | +goto build |
| 23 | +) |
| 24 | + |
| 25 | +if exist %VISUAL_STUDIO_PATH_1% ( |
| 26 | +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_1% |
| 27 | +goto build |
| 28 | +) |
| 29 | + |
| 30 | +if exist %VISUAL_STUDIO_PATH_2% ( |
| 31 | +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_2% |
| 32 | +goto build |
| 33 | +) |
| 34 | + |
| 35 | +if exist %VISUAL_STUDIO_PATH_3% ( |
| 36 | +set VISUAL_STUDIO_PATH=%VISUAL_STUDIO_PATH_3% |
| 37 | +goto build |
| 38 | +) |
| 39 | + |
| 40 | +REM No default path found. Let the user know what to do. |
| 41 | +echo No Visual Studio installation found. Please configure it manually. |
| 42 | +echo 1. Copy 'Paths.cmd.template'. |
| 43 | +echo 2. Rename it to 'Paths.cmd'. |
| 44 | +echo 3. Enter your Visual Studio path in there. |
| 45 | +echo 4. Restart the build. |
| 46 | +REM Allow disabling pause to support non-interacting build chains. |
| 47 | +if NOT "%~1"=="-no-pause" pause |
| 48 | +goto end |
| 49 | +) |
| 50 | + |
| 51 | +:build |
| 52 | +REM Log the used Vistual Studio version. |
| 53 | +@echo on |
| 54 | +%VISUAL_STUDIO_PATH% /p:Configuration=Release |
| 55 | +@echo off |
8 | 56 |
|
9 |
| -:exit |
| 57 | +:end |
10 | 58 | popd
|
11 | 59 | @echo on
|
0 commit comments