@@ -9,24 +9,6 @@ echo %__MsgPrefix%Starting Build at %TIME%
99set __ThisScriptFull = " %~f0 "
1010set __ThisScriptDir = " %~dp0 "
1111
12- call " %__ThisScriptDir% " \native\init-vs-env.cmd
13- if NOT '%ERRORLEVEL% ' == '0' goto ExitWithError
14-
15- if defined VS170COMNTOOLS (
16- set " __VSToolsRoot = %VS170COMNTOOLS% "
17- set " __VCToolsRoot = %VS170COMNTOOLS% \..\..\VC\Auxiliary\Build"
18- set __VSVersion = vs2022
19- )
20- if defined VS160COMNTOOLS (
21- set " __VSToolsRoot = %VS160COMNTOOLS% "
22- set " __VCToolsRoot = %VS160COMNTOOLS% \..\..\VC\Auxiliary\Build"
23- set __VSVersion = vs2019
24- ) else if defined VS150COMNTOOLS (
25- set " __VSToolsRoot = %VS150COMNTOOLS% "
26- set " __VCToolsRoot = %VS150COMNTOOLS% \..\..\VC\Auxiliary\Build"
27- set __VSVersion = vs2017
28- )
29-
3012:: Set the default arguments for build
3113
3214set __TargetArch = x64
@@ -42,11 +24,11 @@ set __Verbosity=minimal
4224set __Ninja = 0
4325
4426:: Set the various build properties here so that CMake and MSBuild can pick them up
45- set " __ProjectDir = %~dp0 "
46- :: remove trailing slash
47- if %__ProjectDir :~-1 % == \ set " __ProjectDir = %__ProjectDir :~0 ,-1 %"
48- set " __ProjectDir = %__ProjectDir % \.."
49- set " __SourceDir = %__ProjectDir % \src"
27+ set " __RepoRootDir = %~dp0 "
28+ :: remove trailing slash
29+ if %__RepoRootDir :~-1 % == \ set " __RepoRootDir = %__RepoRootDir :~0 ,-1 %"
30+ set " __RepoRootDir = %__RepoRootDir % \.."
31+ set " __SourceDir = %__RepoRootDir % \src"
5032
5133:: __UnprocessedBuildArgs are args that we pass to msbuild (e.g. /p:OfficialBuildId=xxxxxx)
5234set " __args = %* "
@@ -89,13 +71,20 @@ if [!processedArgs!] == [] (
8971
9072:ArgsDone
9173
74+ call " %__RepoRootDir% " \eng\native\init-vs-env.cmd
75+ if NOT '%ERRORLEVEL% ' == '0' goto ExitWithError
76+
77+ if defined VCINSTALLDIR (
78+ set " __VCToolsRoot = %VCINSTALLDIR% Auxiliary\Build"
79+ )
80+
9281if " %__HostArch% " == " " set __HostArch = %__TargetArch%
9382if /i " %__BuildType% " == " debug" set __BuildType = Debug
9483if /i " %__BuildType% " == " release" set __BuildType = Release
9584
9685if " %NUGET_PACKAGES% " == " " (
9786 if %__CI% EQU 1 (
98- set " NUGET_PACKAGES = %__ProjectDir % \.packages"
87+ set " NUGET_PACKAGES = %__RepoRootDir % \.packages"
9988 ) else (
10089 set " NUGET_PACKAGES = %UserProfile% \.nuget\packages"
10190 )
@@ -104,7 +93,7 @@ if "%NUGET_PACKAGES%" == "" (
10493echo %NUGET_PACKAGES%
10594
10695:: Set the remaining variables based upon the determined build configuration
107- set " __RootBinDir = %__ProjectDir % \artifacts"
96+ set " __RootBinDir = %__RepoRootDir % \artifacts"
10897set " __BinDir = %__RootBinDir% \bin\%__TargetOS% .%__TargetArch% .%__BuildType% "
10998set " __LogDir = %__RootBinDir% \log\%__TargetOS% .%__TargetArch% .%__BuildType% "
11099set " __ArtifactsIntermediatesDir = %__RootBinDir% \obj"
@@ -128,7 +117,7 @@ echo %__MsgPrefix%Commencing diagnostics repo build
128117
129118echo %__MsgPrefix% Checking prerequisites
130119:: Eval the output from probe-win1.ps1
131- for /f " delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass " & " " %__ProjectDir % \eng\native\set-cmake-path.ps1" " " ') do %%a
120+ for /f " delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass " & " " %__RepoRootDir % \eng\native\set-cmake-path.ps1" " " ') do %%a
132121
133122REM =========================================================================================
134123REM ===
@@ -139,7 +128,7 @@ REM ============================================================================
139128@ if defined _echo @ echo on
140129
141130:: Parse the optdata package versions out of msbuild so that we can pass them on to CMake
142- set __DotNetCli = %__ProjectDir % \dotnet.cmd
131+ set __DotNetCli = %__RepoRootDir % \dotnet.cmd
143132
144133REM =========================================================================================
145134REM ===
@@ -179,7 +168,7 @@ if %__BuildNative% EQU 1 (
179168
180169 echo Generating Version Header
181170 set __GenerateVersionLog = " %__LogDir% \GenerateVersion.binlog"
182- powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File " %__ProjectDir % \eng\common\msbuild.ps1" " %__ProjectDir % \eng\native-prereqs.proj" /bl:!__GenerateVersionLog! /t:BuildPrereqs /restore %__CommonBuildArgs%
171+ powershell -NoProfile -ExecutionPolicy ByPass -NoLogo -File " %__RepoRootDir % \eng\common\msbuild.ps1" " %__RepoRootDir % \eng\native-prereqs.proj" /bl:!__GenerateVersionLog! /t:BuildPrereqs /restore %__CommonBuildArgs%
183172 if not !errorlevel! == 0 (
184173 echo Generate Version Header FAILED
185174 goto ExitWithError
@@ -193,7 +182,7 @@ if %__BuildNative% EQU 1 (
193182 set __ExtraCmakeArgs = !__ExtraCmakeArgs! " -DCMAKE_SYSTEM_VERSION=10.0" " -DCLR_MANAGED_BINARY_DIR=!__ManagedBinaryDir! " " -DCLR_BUILD_TYPE=%__BuildType% " " -DCLR_CMAKE_TARGET_ARCH=%__TargetArch% " " -DNUGET_PACKAGES=%NUGET_PACKAGES:\ =/ % "
194183
195184 pushd " %__IntermediatesDir% "
196- call " %__ProjectDir % \eng\native\gen-buildsys.cmd" " %__ProjectDir % " " %__IntermediatesDir% " %__VSVersion % %__HostArch% %__TargetOS% !__ExtraCmakeArgs!
185+ call " %__RepoRootDir % \eng\native\gen-buildsys.cmd" " %__RepoRootDir % " " %__IntermediatesDir% " %VisualStudioVersion % %__HostArch% %__TargetOS% !__ExtraCmakeArgs!
197186 @ if defined _echo @ echo on
198187 popd
199188
0 commit comments