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