bd03d6f74d31b3b95e49dae94aea02234255d9ee
[platform/upstream/coreclr.git] / build-test.cmd
1 @if not defined _echo @echo off
2 setlocal EnableDelayedExpansion
3
4 :: Set the default arguments for build
5 set __BuildArch=x64
6 set __VCBuildArch=x86_amd64
7 set __BuildType=Debug
8 set __BuildOS=Windows_NT
9
10 set "__ProjectDir=%~dp0"
11
12 :: Define a prefix for most output progress messages that come from this script. That makes
13 :: it easier to see where these are coming from. Note that there is a trailing space here.
14 set "__MsgPrefix=BUILDTEST: "
15
16 call "%__ProjectDir%"\setup_vs_tools.cmd
17
18 REM setup_vs_tools.cmd will correctly echo error message.
19 if NOT '%ERRORLEVEL%' == '0' exit /b 1
20
21 if defined VS150COMNTOOLS (
22   set "__VSToolsRoot=%VS150COMNTOOLS%"
23   set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"
24   set __VSVersion=vs2017
25 ) else (
26   set "__VSToolsRoot=%VS140COMNTOOLS%"
27   set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC"
28   set __VSVersion=vs2015
29 )
30
31 :: remove trailing slash
32 if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
33 set "__TestDir=%__ProjectDir%\tests"
34 set "__ProjectFilesDir=%__TestDir%"
35 set "__SourceDir=%__ProjectDir%\src"
36 set "__PackagesDir=%__ProjectDir%\packages"
37 set "__RootBinDir=%__ProjectDir%\bin"
38 set "__LogsDir=%__RootBinDir%\Logs"
39
40 :: Default __Exclude to issues.targets
41 set __Exclude=%__TestDir%\issues.targets
42
43 REM __unprocessedBuildArgs are args that we pass to msbuild (e.g. /p:__BuildArch=x64)
44 set "__args= %*"
45 set processedArgs=
46 set __unprocessedBuildArgs=
47 set __RunArgs=
48 set __BuildAgainstPackagesArg=
49 set __RuntimeId=
50 set __ZipTests=
51 set __TargetsWindows=1
52 set __DoCrossgen=
53
54 :Arg_Loop
55 if "%1" == "" goto ArgsDone
56
57 if /i "%1" == "-?"    goto Usage
58 if /i "%1" == "-h"    goto Usage
59 if /i "%1" == "-help" goto Usage
60
61 if /i "%1" == "x64"                   (set __BuildArch=x64&set __VCBuildArch=x86_amd64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
62 if /i "%1" == "x86"                   (set __BuildArch=x86&set __VCBuildArch=x86&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
63 if /i "%1" == "arm"                   (set __BuildArch=arm&set __VCBuildArch=x86_arm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
64 if /i "%1" == "arm64"                 (set __BuildArch=arm64&set __VCBuildArch=x86_arm64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
65
66 if /i "%1" == "debug"                 (set __BuildType=Debug&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
67 if /i "%1" == "release"               (set __BuildType=Release&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
68 if /i "%1" == "checked"               (set __BuildType=Checked&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
69
70 if /i "%1" == "skipmanaged"           (set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
71 if /i "%1" == "toolset_dir"           (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
72 if /i "%1" == "buildagainstpackages"  (set __ZipTests=1&set __BuildAgainstPackagesArg=-BuildTestsAgainstPackages&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
73 if /i "%1" == "ziptests"              (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
74 if /i "%1" == "crossgen"              (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
75 if /i "%1" == "runtimeid"             (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
76 if /i "%1" == "targetsNonWindows"     (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
77 if /i "%1" == "Exclude"               (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
78
79 if [!processedArgs!]==[] (
80   set __UnprocessedBuildArgs=%__args%
81 ) else (
82   set __UnprocessedBuildArgs=%__args%
83   for %%t in (!processedArgs!) do (
84     set __UnprocessedBuildArgs=!__UnprocessedBuildArgs:*%%t=!
85   )
86 )
87
88 :ArgsDone
89
90 if defined __BuildAgainstPackagesArg (
91     if not defined __RuntimeID (
92         echo %__MsgPrefix%Error: When building against packages, you must supply a target Runtime ID.
93         exit /b 1
94     )
95 )
96
97 @if defined _echo @echo on
98
99 set __RunArgs=-BuildOS=%__BuildOS% -BuildType=%__BuildType% -BuildArch=%__BuildArch%
100
101 if defined __ToolsetDir (
102     rem arm64 builds currently use private toolset which has not been released yet
103     REM TODO, remove once the toolset is open.
104     call :PrivateToolSet
105 )
106
107 echo %__MsgPrefix%Commencing CoreCLR repo test build
108
109 set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
110 set "__TestRootDir=%__RootBinDir%\tests"
111 set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
112 :: We have different managed and native intermediate dirs because the managed bits will include
113 :: the configuration information deeper in the intermediates path.
114 :: These variables are used by the msbuild project files.
115
116 if not defined __TestIntermediateDir (
117     set "__TestIntermediateDir=tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
118 )
119 set "__NativeTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Native"
120 set "__ManagedTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Managed"
121
122 :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
123 set "__CMakeBinDir=%__TestBinDir%"
124 set "__CMakeBinDir=%__CMakeBinDir:\=/%"
125
126 if not exist "%__TestBinDir%"                   md "%__TestBinDir%"
127 if not exist "%__NativeTestIntermediatesDir%"   md "%__NativeTestIntermediatesDir%"
128 if not exist "%__ManagedTestIntermediatesDir%"  md "%__ManagedTestIntermediatesDir%"
129 if not exist "%__LogsDir%"                      md "%__LogsDir%"
130
131 echo %__MsgPrefix%Checking prerequisites
132
133 :: Eval the output from probe-win1.ps1
134 for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a
135
136 REM =========================================================================================
137 REM ===
138 REM === Restore Build Tools
139 REM ===
140 REM =========================================================================================
141 call "%__ProjectDir%\init-tools.cmd"
142 @if defined _echo @echo on
143
144 REM =========================================================================================
145 REM ===
146 REM === Resolve runtime dependences
147 REM ===
148 REM =========================================================================================
149
150 call "%__TestDir%\setup-stress-dependencies.cmd" /arch %__BuildArch% /outputdir %__BinDir%
151 @if defined _echo @echo on
152
153 REM =========================================================================================
154 REM ===
155 REM === Native test build section
156 REM ===
157 REM =========================================================================================
158
159 echo %__MsgPrefix%Commencing build of native test components for %__BuildArch%/%__BuildType%
160
161 if defined __ToolsetDir (
162     echo %__MsgPrefix%ToolsetDir is defined to be %__ToolsetDir%
163     goto GenVSSolution :: Private ToolSet is Defined
164 )
165
166 :: Set the environment for the native build
167 echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch%
168 call                                 "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch%
169 @if defined _echo @echo on
170
171 if not defined VSINSTALLDIR (
172     echo %__MsgPrefix%Error: VSINSTALLDIR variable not defined.
173     exit /b 1
174 )
175 if not exist "%VSINSTALLDIR%DIA SDK" goto NoDIA
176
177 :GenVSSolution
178
179 pushd "%__NativeTestIntermediatesDir%"
180 call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" ""%__ProjectFilesDir%"" %__VSVersion% %__BuildArch%
181 @if defined _echo @echo on
182 popd
183
184 if not exist "%__NativeTestIntermediatesDir%\install.vcxproj" (
185     echo %__MsgPrefix%Failed to generate test native component build project!
186     exit /b 1
187 )
188
189 set __msbuildNativeArgs=-configuration=%__BuildType%
190
191 if defined __ToolsetDir (
192     set __msbuildNativeArgs=%__msbuildNativeArgs% -UseEnv
193 ) else (
194     set __msbuildNativeArgs=%__msbuildNativeArgs% -platform=%__BuildArch%
195 )
196
197 set __BuildLogRootName=Tests_Native
198 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
199 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
200 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
201 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
202 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
203 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
204
205 call "%__ProjectDir%\run.cmd" build -Project="%__NativeTestIntermediatesDir%\install.vcxproj" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__msbuildNativeArgs% %__RunArgs% %__unprocessedBuildArgs%
206 if errorlevel 1 (
207     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
208     echo     %__BuildLog%
209     echo     %__BuildWrn%
210     echo     %__BuildErr%
211     exit /b 1
212 )
213
214 :skipnative
215
216 set "__TestWorkingDir=%__RootBinDir%\tests\%__BuildOS%.%__BuildArch%.%__BuildType%"
217
218 if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct
219 REM =========================================================================================
220 REM ===
221 REM === Restore product binaries from packages
222 REM ===
223 REM =========================================================================================
224
225 if not defined XunitTestBinBase       set  XunitTestBinBase=%__TestWorkingDir%
226 set "CORE_ROOT=%XunitTestBinBase%\Tests\Core_Root"
227
228 set __BuildLogRootName=Restore_Product
229 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
230 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
231 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
232 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
233 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
234 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
235
236 call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -BatchRestorePackages -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
237
238 set __BuildLogRootName=Tests_GenerateRuntimeLayout
239 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
240 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
241 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
242 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
243 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
244 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
245
246 call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\runtest.proj -BinPlaceRef -BinPlaceProduct -CopyCrossgenToProduct -RuntimeId="%__RuntimeId%" -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
247 if errorlevel 1 (
248     echo BinPlace of mscorlib.dll failed
249     exit /b 1
250 )
251
252 echo %__MsgPrefix% Restored CoreCLR product from packages
253
254 :SkipRestoreProduct
255
256 if defined __SkipManaged exit /b 0
257
258 REM =========================================================================================
259 REM ===
260 REM === Managed test build section
261 REM ===
262 REM =========================================================================================
263
264 echo %__MsgPrefix%Starting the Managed Tests Build
265
266 if not defined VSINSTALLDIR (
267     echo %__MsgPrefix%Error: build-test.cmd should be run from a Visual Studio Command Prompt.  Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
268     exit /b 1
269 )
270
271 set __BuildLogRootName=Tests_Managed
272 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
273 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
274 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
275 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
276 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
277 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
278
279 call "%__ProjectDir%\run.cmd" build -Project=%__ProjectDir%\tests\build.proj -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %__unprocessedBuildArgs%
280 if errorlevel 1 (
281     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
282     echo     %__BuildLog%
283     echo     %__BuildWrn%
284     echo     %__BuildErr%
285     exit /b 1
286 )
287
288 REM Prepare the Test Drop
289 REM Cleans any NI from the last run
290 powershell -NoProfile "Get-ChildItem -path %__TestWorkingDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force"
291 REM Cleans up any lock folder used for synchronization from last run
292 powershell -NoProfile "Get-ChildItem -path %__TestWorkingDir% -Include 'lock' -Recurse -Force |  where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse"
293
294 set CORE_ROOT=%__TestBinDir%\Tests\Core_Root
295 set CORE_ROOT_STAGE=%__TestBinDir%\Tests\Core_Root_Stage
296 if exist "%CORE_ROOT%" rd /s /q "%CORE_ROOT%"
297 if exist "%CORE_ROOT_STAGE%" rd /s /q "%CORE_ROOT_STAGE%"
298 md "%CORE_ROOT%"
299 md "%CORE_ROOT_STAGE%"
300 xcopy "%__BinDir%" "%CORE_ROOT_STAGE%"
301
302
303 if defined __BuildAgainstPackagesArg ( 
304   if "%__TargetsWindows%"=="0" (
305
306     if not exist %__PackagesDir%\TestNativeBins (
307         echo %__MsgPrefix%Error: Ensure you have run sync.cmd -ab before building a non-Windows test overlay against packages
308         exit /b 1
309     )
310
311     for /R %__PackagesDir%\TestNativeBins\%__RuntimeId%\%__BuildType% %%f in (*.so) do copy %%f %CORE_ROOT_STAGE%
312     for /R %__PackagesDir%\TestNativeBins\%__RuntimeId%\%__BuildType% %%f in (*.dylib) do copy %%f %CORE_ROOT_STAGE%
313   )
314 )
315
316 echo %__MsgPrefix%Creating test wrappers...
317
318 set RuntimeIdArg=
319 set TargetsWindowsArg=
320
321 if defined __RuntimeId (
322     set RuntimeIdArg=-RuntimeID="%__RuntimeId%"
323 )
324
325 if "%__TargetsWindows%"=="1" (
326     set TargetsWindowsArg=-TargetsWindows=true
327 ) else if "%__TargetsWindows%"=="0" (
328     set TargetsWindowsArg=-TargetsWindows=false
329 )
330
331 set __BuildLogRootName=Tests_XunitWrapper
332 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
333 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
334 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
335 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
336 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
337 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
338
339 call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -BuildWrappers -MsBuildEventLogging=" " -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %TargetsWindowsArg% %__unprocessedBuildArgs%
340 if errorlevel 1 (
341     echo Xunit Wrapper build failed
342     exit /b 1
343 )
344
345 echo %__MsgPrefix%Creating test overlay...
346
347 set __BuildLogRootName=Tests_Overlay_Managed
348 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
349 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
350 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
351 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
352 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
353 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
354
355 call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\runtest.proj -testOverlay -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %RuntimeIdArg% %__unprocessedBuildArgs%
356 if errorlevel 1 (
357     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
358     echo     %__BuildLog%
359     echo     %__BuildWrn%
360     echo     %__BuildErr%
361     exit /b 1
362 )
363
364 xcopy /s /y "%CORE_ROOT_STAGE%" "%CORE_ROOT%"
365
366 set __CrossgenArg = ""
367 if defined __DoCrossgen (
368   set __CrossgenArg="-Crossgen"
369   if "%__TargetsWindows%" == "1" (
370     call :PrecompileFX
371   ) else (
372     echo "%__MsgPrefix% Crossgen only supported on Windows, for now"
373   )
374 )
375
376 rd /s /q "%CORE_ROOT_STAGE%"
377
378 if not defined __ZipTests goto SkipPrepForPublish
379
380 set __BuildLogRootName=Helix_Prep
381 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
382 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
383 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
384 set __msbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
385 set __msbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
386 set __msbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
387
388 REM =========================================================================================
389 REM ===
390 REM === Prep test binaries for Helix publishing
391 REM ===
392 REM =========================================================================================
393
394 call %__ProjectDir%\run.cmd build -Project=%__ProjectDir%\tests\helixprep.proj  -MsBuildLog=!__msbuildLog! -MsBuildWrn=!__msbuildWrn! -MsBuildErr=!__msbuildErr! %__RunArgs% %__BuildAgainstPackagesArg% %RuntimeIdArg% %TargetsWindowsArg% %__CrossgenArg% %__unprocessedBuildArgs%
395 if errorlevel 1 (
396     echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
397     echo     %__BuildLog%
398     echo     %__BuildWrn%
399     echo     %__BuildErr%
400     exit /b 1
401 )
402
403 echo %__MsgPrefix% Prepped test binaries for publishing
404
405 :SkipPrepForPublish
406
407 REM =========================================================================================
408 REM ===
409 REM === All builds complete!
410 REM ===
411 REM =========================================================================================
412
413 echo %__MsgPrefix%Test build successful.
414 echo %__MsgPrefix%Test binaries are available at !__TestBinDir!
415 exit /b 0
416
417 :Usage
418 echo.
419 echo Usage:
420 echo     %0 [option1] [option2] ...
421 echo All arguments are optional. Options are case-insensitive. The options are:
422 echo.
423 echo. -? -h -help: view this message.
424 echo Build architecture: -buildArch: only x64 is currently allowed ^(default: x64^).
425 echo Build type: -buildType: one of Debug, Checked, Release ^(default: Debug^).
426 echo buildagainstpackages: builds tests against restored packages, instead of against a built product.
427 echo runtimeid ^<ID^>: Builds a test overlay for the specified OS (Only supported when building against packages). Supported IDs are:
428 echo     alpine.3.4.3-x64: Builds overlay for Alpine 3.4.3
429 echo     debian.8-x64: Builds overlay for Debian 8
430 echo     fedora.24-x64: Builds overlay for Fedora 24
431 echo     linux-x64: Builds overlay for portable linux
432 echo     opensuse.42.1-x64: Builds overlay for OpenSUSE 42.1
433 echo     osx.10.12-x64: Builds overlay for OSX 10.12
434 echo     osx-x64: Builds overlay for portable OSX
435 echo     rhel.7-x64: Builds overlay for RHEL 7 or CentOS
436 echo     ubuntu.14.04-x64: Builds overlay for Ubuntu 14.04
437 echo     ubuntu.16.04-x64: Builds overlay for Ubuntu 16.04
438 echo     ubuntu.16.10-x64: Builds overlay for Ubuntu 16.10
439 echo     win-x64: Builds overlay for portable Windows
440 echo     win7-x64: Builds overlay for Windows 7
441 echo ziptests: zips CoreCLR tests & Core_Root for a Helix run
442 echo crossgen: Precompiles the framework managed assemblies
443 echo Exclude- Optional parameter - specify location of default exclusion file (defaults to tests\issues.targets if not specified)
444 echo     Set to "" to disable default exclusion file.
445 echo -- ... : all arguments following this tag will be passed directly to msbuild.
446 echo -priority=^<N^> : specify a set of test that will be built and run, with priority N.
447 echo     0: Build only priority 0 cases as essential testcases (default)
448 echo     1: Build all tests with priority 0 and 1
449 echo     666: Build all tests with priority 0, 1 ... 666
450 echo -verbose: enables detailed file logging for the msbuild tasks into the msbuild log file.
451 exit /b 1
452
453 :NoDIA
454 echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
455 This is due to a bug in the Visual Studio installer. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
456 at the install location of previous Visual Studio version. The workaround is to copy the DIA SDK folder from the Visual Studio install location ^
457 of the previous version to "%VSINSTALLDIR%" and then build.
458 :: DIA SDK not included in Express editions
459 echo Visual Studio Express does not include the DIA SDK. ^
460 You need Visual Studio 2015 or 2017 (Community is free).
461 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
462 exit /b 1
463
464
465 :PrivateToolSet
466
467 echo %__MsgPrefix%Setting up the usage of __ToolsetDir:%__ToolsetDir%
468
469 if /i "%__ToolsetDir%" == "" (
470     echo %__MsgPrefix%Error: A toolset directory is required for the Arm64 Windows build. Use the toolset_dir argument.
471     exit /b 1
472 )
473
474 if not exist "%__ToolsetDir%"\buildenv_arm64.cmd goto :Not_EWDK
475 call "%__ToolsetDir%"\buildenv_arm64.cmd
476 exit /b 0
477
478 :Not_EWDK
479 set PATH=%__ToolsetDir%\VC_sdk\bin;%PATH%
480 set LIB=%__ToolsetDir%\VC_sdk\lib\arm64;%__ToolsetDir%\sdpublic\sdk\lib\arm64
481 set INCLUDE=^
482 %__ToolsetDir%\VC_sdk\inc;^
483 %__ToolsetDir%\sdpublic\sdk\inc;^
484 %__ToolsetDir%\sdpublic\shared\inc;^
485 %__ToolsetDir%\sdpublic\shared\inc\minwin;^
486 %__ToolsetDir%\sdpublic\sdk\inc\ucrt;^
487 %__ToolsetDir%\sdpublic\sdk\inc\minwin;^
488 %__ToolsetDir%\sdpublic\sdk\inc\mincore;^
489 %__ToolsetDir%\sdpublic\sdk\inc\abi;^
490 %__ToolsetDir%\sdpublic\sdk\inc\clientcore;^
491 %__ToolsetDir%\diasdk\include
492 exit /b 0
493
494 :PrecompileFX
495 for %%F in (%CORE_ROOT%\*.dll) do call :PrecompileAssembly "%%F" %%~nF%%~xF
496 exit /b 0
497
498 REM Compile the managed assemblies in Core_ROOT before running the tests
499 :PrecompileAssembly
500
501 REM Skip mscorlib since it is already precompiled.
502 if /I "%2" == "mscorlib.dll" exit /b 0
503 if /I "%2" == "mscorlib.ni.dll" exit /b 0
504 REM don't precompile anything from CoreCLR
505 if /I exist %CORE_ROOT_STAGE%\%2 exit /b 0
506
507 "%CORE_ROOT_STAGE%\crossgen.exe" /Platform_Assemblies_Paths "%CORE_ROOT%" /in "%1" /out "%CORE_ROOT%/temp.ni.dll" >nul 2>nul
508 set /a __exitCode = %errorlevel%
509 if "%__exitCode%" == "-2146230517" (
510     echo %2 is not a managed assembly.
511     exit /b 0
512 )
513
514 if %__exitCode% neq 0 (
515     echo Unable to precompile %2
516     exit /b 0
517 )
518
519 :: Delete original .dll & replace it with the Crossgened .dll
520 del %1
521 ren "%CORE_ROOT%\temp.ni.dll" %2
522     
523 echo Successfully precompiled %2
524 exit /b 0