1
1
@ echo off
2
- pushd %~dp0
3
2
setlocal
4
3
5
4
if exist bin goto Build
@@ -29,7 +28,7 @@ for /f "usebackq tokens=*" %%i in (`%vswhere% -version 16 -latest -prerelease -p
29
28
-requires Microsoft.Net.Component.4.5.2.TargetingPack ^
30
29
-requires Microsoft.Net.Component.4.6.2.TargetingPack ^
31
30
-property installationPath`) do (
32
- set InstallDir = " %%i "
31
+ set " InstallDir = %%i "
33
32
)
34
33
35
34
if not DEFINED InstallDir (
@@ -38,49 +37,63 @@ if not DEFINED InstallDir (
38
37
goto BuildFail
39
38
)
40
39
41
- REM Find or install MSBuild. Need v17.4 due to our .NET SDK choice.
42
- set " MSBuildVersion = 17.4.1 "
43
- set " Command = [System.Threading.Thread]::CurrentThread.CurrentCulture = '' "
44
- set " Command = %Command% ; [System.Threading.Thread]::CurrentThread.CurrentUICulture = '' "
45
- set " Command = %Command% ; try { & ' %~dp0 eng\GetXCopyMSBuild.ps1' %MSBuildVersion% ; exit $LASTEXITCODE } "
46
- set " Command = %Command% catch { write-host $_; exit 1 } "
47
- PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command " %Command% "
48
- if %ERRORLEVEL% neq 0 goto BuildFail
40
+ REM Find a 64bit MSBuild and add it to path. Require v17.4 or later due to our .NET SDK choice.
41
+ REM Check for VS2022 first.
42
+ set InstallDir =
43
+ for /f " usebackq tokens=* " %%i in (` %vswhere% -version 17.4 -latest -prerelease -products * ^
44
+ -requires Microsoft.Component.MSBuild ^
45
+ -property installationPath`) do (
46
+ set " InstallDir = %%i "
47
+ )
49
48
50
- REM Add MSBuild to the path.
51
- set " PATH = %CD% \.msbuild\%MSBuildVersion% \tools\MSBuild\Current\Bin\;%PATH% "
49
+ if DEFINED InstallDir (
50
+ REM Add MSBuild to the path.
51
+ set " PATH = %InstallDir% \MSBuild\Current\Bin\amd64;%PATH% "
52
+ ) else (
53
+ REM Otherwise find or install an xcopy-able MSBuild.
54
+ echo " Could not find a VS2022 installation with the necessary components (MSBuild). Falling back..."
55
+
56
+ set " MSBuildVersion = 17.4.1"
57
+ set " Command = [System.Threading.Thread]::CurrentThread.CurrentCulture = ''"
58
+ set " Command = %Command% ; [System.Threading.Thread]::CurrentThread.CurrentUICulture = ''"
59
+ set " Command = %Command% ; try { & '%~dp0 eng\GetXCopyMSBuild.ps1' %MSBuildVersion% ; exit $LASTEXITCODE }"
60
+ set " Command = %Command% catch { write-host $_; exit 1 }"
61
+ PowerShell -NoProfile -NoLogo -ExecutionPolicy Bypass -Command " %Command% "
62
+ if %ERRORLEVEL% neq 0 goto BuildFail
63
+
64
+ REM Add MSBuild to the path.
65
+ set " PATH = %~dp0 .msbuild\%MSBuildVersion% \tools\MSBuild\Current\Bin\amd64;%PATH% "
66
+ )
52
67
53
68
REM Configure NuGet operations to work w/in this repo i.e. do not pollute system packages folder.
54
69
REM Note this causes two copies of packages restored using packages.config to land in this folder e.g.
55
70
REM StyleCpy.5.0.0/ and stylecop/5.0.0/.
56
- set " NUGET_PACKAGES = %CD% \packages "
71
+ set " NUGET_PACKAGES = %~dp0 packages "
57
72
58
73
REM Are we running in a local dev environment (not on CI)?
59
74
if DEFINED CI (set Desktop=false) else if DEFINED TEAMCITY_VERSION (set Desktop=false) else (set Desktop=true)
60
75
61
76
if " %1 " == " " goto BuildDefaults
62
77
63
- MSBuild Runtime .msbuild /m /nr:false /p:Platform=" Any CPU" /p:Desktop=%Desktop% /v:M ^
78
+ MSBuild " %~dp0 Runtime .msbuild" /m /nr:false /p:Platform=" Any CPU" /p:Desktop=%Desktop% /v:M ^
64
79
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary /t:%*
65
80
if %ERRORLEVEL% neq 0 goto BuildFail
66
81
goto BuildSuccess
67
82
68
83
:BuildDefaults
69
- MSBuild Runtime .msbuild /m /nr:false /p:Platform=" Any CPU" /p:Desktop=%Desktop% /v:M ^
84
+ MSBuild " %~dp0 Runtime .msbuild" /m /nr:false /p:Platform=" Any CPU" /p:Desktop=%Desktop% /v:M ^
70
85
/fl /fileLoggerParameters:LogFile=bin\msbuild.log;Verbosity=Normal /consoleLoggerParameters:Summary
71
86
if %ERRORLEVEL% neq 0 goto BuildFail
72
87
goto BuildSuccess
73
88
74
89
:BuildFail
75
90
echo .
76
91
echo *** BUILD FAILED ***
77
- popd
78
92
endlocal
79
93
exit /B 999
80
94
81
95
:BuildSuccess
82
96
echo .
83
97
echo **** BUILD SUCCESSFUL ***
84
- popd
85
98
endlocal
86
99
exit /B 0
0 commit comments