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