-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMSBuild.bat
45 lines (38 loc) · 1.19 KB
/
MSBuild.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
:: MSBuild.exe %*
@echo off
setlocal
:: cd /d %~dp0
set PF32=%ProgramFiles(x86)%
if not exist "%PF32%" set PF32=%ProgramFiles%
set VsWherePath="%PF32%\Microsoft Visual Studio\Installer\vswhere.exe"
:: vs2019 or later
for /f "usebackq tokens=*" %%i in (`%VsWherePath% -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe`) do (
if exist "%%i" (
set MSBuildPath="%%i"
goto :run
)
)
:: vs2017 or earlier
for /f "usebackq tokens=1* delims=: " %%i in (`%VsWherePath% -latest -requires Microsoft.Component.MSBuild`) do (
if /i "%%i"=="installationPath" (
if exist "%%j\MSBuild\15.0\Bin\MSBuild.exe" (
set MSBuildPath="%%j\MSBuild\15.0\Bin\MSBuild.exe"
goto :run
)
if exist "%%j\MSBuild\14.0\Bin\MSBuild.exe" (
set MSBuildPath="%%j\MSBuild\14.0\Bin\MSBuild.exe"
goto :run
)
if exist "%%j\MSBuild\12.0\Bin\MSBuild.exe" (
set MSBuildPath="%%j\MSBuild\12.0\Bin\MSBuild.exe"
goto :run
)
)
)
:run
if not exist %MSBuildPath% (
echo "MSBuild.exe not find"
exit /b 1
)
echo on
%MSBuildPath% %*