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