1 @if not defined _echo @echo off
2 setlocal EnableDelayedExpansion EnableExtensions
4 :: Define a prefix for most output progress messages that come from this script. That makes
5 :: it easier to see where these are coming from. Note that there is a trailing space here.
6 set "__MsgPrefix=BUILDTEST: "
8 echo %__MsgPrefix%Starting Build at %TIME%
10 set __ThisScriptDir="%~dp0"
12 call "%__ThisScriptDir%"\setup_vs_tools.cmd
13 if NOT '%ERRORLEVEL%' == '0' exit /b 1
15 if defined VS150COMNTOOLS (
16 set "__VSToolsRoot=%VS150COMNTOOLS%"
17 set "__VCToolsRoot=%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build"
18 set __VSVersion=vs2017
20 set "__VSToolsRoot=%VS140COMNTOOLS%"
21 set "__VCToolsRoot=%VS140COMNTOOLS%\..\..\VC"
22 set __VSVersion=vs2015
25 :: Set the default arguments for build
28 set __BuildOS=Windows_NT
30 set "__ProjectDir=%~dp0"
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"
40 :: Default __Exclude to issues.targets
41 set __Exclude=%__TestDir%\issues.targets
43 REM __UnprocessedBuildArgs are args that we pass to msbuild (e.g. /p:__BuildArch=x64)
46 set __UnprocessedBuildArgs=
47 set __CommonMSBuildArgs=
49 set __BuildAgainstPackagesArg=
50 set __SkipRestorePackages=
55 set __TargetsWindows=1
58 @REM CMD has a nasty habit of eating "=" on the argument list, so passing:
60 @REM appears to CMD parsing as "-priority 1". Handle -priority specially to avoid problems,
61 @REM and allow the "-priority=1" syntax.
66 if "%1" == "" goto ArgsDone
68 if /i "%1" == "/?" goto Usage
69 if /i "%1" == "-?" goto Usage
70 if /i "%1" == "/h" goto Usage
71 if /i "%1" == "-h" goto Usage
72 if /i "%1" == "/help" goto Usage
73 if /i "%1" == "-help" goto Usage
74 if /i "%1" == "--help" goto Usage
76 if /i "%1" == "x64" (set __BuildArch=x64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
77 if /i "%1" == "x86" (set __BuildArch=x86&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
78 if /i "%1" == "arm" (set __BuildArch=arm&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
79 if /i "%1" == "arm64" (set __BuildArch=arm64&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
81 if /i "%1" == "debug" (set __BuildType=Debug&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
82 if /i "%1" == "release" (set __BuildType=Release&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
83 if /i "%1" == "checked" (set __BuildType=Checked&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
85 if /i "%1" == "skipmanaged" (set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
86 if /i "%1" == "skipnative" (set __SkipNative=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
87 if /i "%1" == "buildtesthostonly" (set __SkipNative=1&set __SkipManaged=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
88 if /i "%1" == "buildagainstpackages" (set __ZipTests=1&set __BuildAgainstPackagesArg=/p:BuildTestsAgainstPackages=true&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
89 if /i "%1" == "skiprestorepackages" (set __SkipRestorePackages=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
90 if /i "%1" == "ziptests" (set __ZipTests=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
91 if /i "%1" == "crossgen" (set __DoCrossgen=1&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
92 if /i "%1" == "runtimeid" (set __RuntimeId=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
93 if /i "%1" == "targetsNonWindows" (set __TargetsWindows=0&set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
94 if /i "%1" == "Exclude" (set __Exclude=%2&set processedArgs=!processedArgs! %1 %2&shift&shift&goto Arg_Loop)
95 if /i "%1" == "-priority" (set __Priority=%2&shift&set processedArgs=!processedArgs! %1=%2&shift&goto Arg_Loop)
96 if /i "%1" == "--" (set processedArgs=!processedArgs! %1&shift&goto Arg_Loop)
98 if [!processedArgs!]==[] (
99 set __UnprocessedBuildArgs=%__args%
101 set __UnprocessedBuildArgs=%__args%
102 for %%t in (!processedArgs!) do (
103 set __UnprocessedBuildArgs=!__UnprocessedBuildArgs:*%%t=!
109 @REM Special handling for -priority=N argument.
110 if %__Priority% GTR 0 (
111 set "__PriorityArg=/p:CLRTestPriorityToBuild=%__Priority%"
114 if defined __BuildAgainstPackagesArg (
115 if not defined __RuntimeID (
116 echo %__MsgPrefix%Error: When building against packages, you must supply a target Runtime ID.
121 set TargetsWindowsArg=
122 set TargetsWindowsMsbuildArg=
123 if "%__TargetsWindows%"=="1" (
124 set TargetsWindowsArg=-TargetsWindows=true
125 set TargetsWindowsMsbuildArg=/p:TargetsWindows=true
126 ) else if "%__TargetsWindows%"=="0" (
127 set TargetsWindowsArg=-TargetsWindows=false
128 set TargetsWindowsMsbuildArg=/p:TargetsWindows=false
131 @if defined _echo @echo on
133 set __CommonMSBuildArgs=/p:__BuildOS=%__BuildOS% /p:__BuildType=%__BuildType% /p:__BuildArch=%__BuildArch%
134 REM As we move from buildtools to arcade, __RunArgs should be replaced with __msbuildArgs
135 set __msbuildArgs=/p:__BuildOS=%__BuildOS% /p:__BuildType=%__BuildType% /p:__BuildArch=%__BuildArch% /nologo /verbosity:minimal /clp:Summary /maxcpucount
137 echo %__MsgPrefix%Commencing CoreCLR test build
139 set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
140 set "__TestRootDir=%__RootBinDir%\tests"
141 set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
143 REM We have different managed and native intermediate dirs because the managed bits will include
144 REM the configuration information deeper in the intermediates path.
145 REM These variables are used by the msbuild project files.
147 if not defined __TestIntermediateDir (
148 set "__TestIntermediateDir=tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
150 set "__NativeTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Native"
151 set "__ManagedTestIntermediatesDir=%__RootBinDir%\%__TestIntermediateDir%\Managed"
153 REM Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
154 set "__CMakeBinDir=%__TestBinDir%"
155 set "__CMakeBinDir=%__CMakeBinDir:\=/%"
157 if not exist "%__TestBinDir%" md "%__TestBinDir%"
158 if not exist "%__NativeTestIntermediatesDir%" md "%__NativeTestIntermediatesDir%"
159 if not exist "%__ManagedTestIntermediatesDir%" md "%__ManagedTestIntermediatesDir%"
160 if not exist "%__LogsDir%" md "%__LogsDir%"
162 echo %__MsgPrefix%Checking prerequisites
164 REM Eval the output from set-cmake-path.ps1
165 for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy ByPass "& ""%__SourceDir%\pal\tools\set-cmake-path.ps1"""') do %%a
167 REM =========================================================================================
169 REM === Restore Build Tools
171 REM =========================================================================================
173 call "%__ProjectDir%\init-tools.cmd"
174 @if defined _echo @echo on
176 set "__ToolsDir=%__ProjectDir%\Tools"
177 set "DotNetCli=%__ToolsDir%\dotnetcli\dotnet.exe"
178 if not exist "%DotNetCli%" (
179 echo %__MsgPrefix%"%DotNetCli%" not found after init-tools.
183 REM =========================================================================================
185 REM === Resolve runtime dependences
187 REM =========================================================================================
189 call "%__TestDir%\setup-stress-dependencies.cmd" /arch %__BuildArch% /outputdir %__BinDir%
190 @if defined _echo @echo on
192 REM =========================================================================================
194 REM === Native test build section
196 REM =========================================================================================
198 if defined __SkipNative goto skipnative
200 echo %__MsgPrefix%Commencing build of native test components for %__BuildArch%/%__BuildType%
202 REM Set the environment for the native build
203 set __VCBuildArch=x86_amd64
204 if /i "%__BuildArch%" == "x86" ( set __VCBuildArch=x86 )
205 if /i "%__BuildArch%" == "arm" ( set __VCBuildArch=x86_arm )
206 if /i "%__BuildArch%" == "arm64" ( set __VCBuildArch=x86_arm64 )
208 echo %__MsgPrefix%Using environment: "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch%
209 call "%__VCToolsRoot%\vcvarsall.bat" %__VCBuildArch%
210 @if defined _echo @echo on
212 if not defined VSINSTALLDIR (
213 echo %__MsgPrefix%Error: VSINSTALLDIR variable not defined.
216 if not exist "%VSINSTALLDIR%DIA SDK" goto NoDIA
218 pushd "%__NativeTestIntermediatesDir%"
219 call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" ""%__ProjectFilesDir%"" %__VSVersion% %__BuildArch%
220 @if defined _echo @echo on
223 if not exist "%__NativeTestIntermediatesDir%\install.vcxproj" (
224 echo %__MsgPrefix%Failed to generate test native component build project!
228 set __BuildLogRootName=Tests_Native
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 set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
237 call "%__ProjectDir%\msbuild.cmd" /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^
238 /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^
239 /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^
240 /p:UsePartialNGENOptimization=false /maxcpucount^
241 "%__NativeTestIntermediatesDir%\install.vcxproj"^
242 !__Logging! /p:Configuration=%__BuildType% /p:Platform=%__BuildArch% %__CommonMSBuildArgs% %__PriorityArg% %__UnprocessedBuildArgs%
244 echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
253 REM =========================================================================================
255 REM === Restore product binaries from packages
257 REM =========================================================================================
259 if "%__SkipRestorePackages%" == 1 goto SkipRestoreProduct
261 echo %__MsgPrefix%Restoring CoreCLR product from packages
263 if not defined XunitTestBinBase set XunitTestBinBase=%__TestBinDir%
264 set "CORE_ROOT=%XunitTestBinBase%\Tests\Core_Root"
266 set __BuildLogRootName=Restore_Product
267 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
268 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
269 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
270 set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
271 set __MsbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
272 set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
273 set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
275 call "%__ProjectDir%\msbuild.cmd" /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^
276 /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^
277 /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^
278 /p:UsePartialNGENOptimization=false /maxcpucount^
279 %__ProjectDir%\tests\build.proj /t:BatchRestorePackages^
280 !__Logging! %__CommonMSBuildArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__UnprocessedBuildArgs%
282 if not defined __BuildAgainstPackagesArg goto SkipRestoreProduct
284 echo %__MsgPrefix%BinPlacing CoreLib
286 set __BuildLogRootName=Tests_GenerateRuntimeLayout
287 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
288 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
289 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
290 set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
291 set __MsbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
292 set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
293 set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
295 call "%__ProjectDir%\msbuild.cmd" /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^
296 /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^
297 /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^
298 /p:UsePartialNGENOptimization=false /maxcpucount^
299 %__Projectdir%\tests\runtest.proj /t:BinPlaceRef /t:BinPlaceProduct /t:CopyCrossgenToProduct /p:RuntimeId="%__RuntimeId%"^
300 !__Logging! %__CommonMSBuildArgs% %__BuildAgainstPackagesArg% %__PriorityArg% %__UnprocessedBuildArgs%
302 echo %__MsgPrefix%Error: BinPlace of mscorlib.dll failed. Refer to the build log files for details:
311 REM =========================================================================================
313 REM === Managed test build section
315 REM =========================================================================================
317 if defined __SkipManaged goto SkipManagedBuild
319 echo %__MsgPrefix%Starting the Managed Tests Build
321 if not defined VSINSTALLDIR (
322 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.
325 set __AppendToLog=false
326 set __BuildLogRootName=Tests_Managed
327 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
328 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
329 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
331 REM Execute msbuild test build in stages - workaround for excessive data retention in MSBuild ConfigCache
332 REM See https://github.com/Microsoft/msbuild/issues/2993
334 set __SkipPackageRestore=false
335 set __SkipTargetingPackBuild=false
336 set __BuildLoopCount=2
337 set __TestGroupToBuild=1
339 if %__Priority% GTR 0 (set __BuildLoopCount=16&set __TestGroupToBuild=2)
340 echo %__MsgPrefix%Building tests group %__TestGroupToBuild% with %__BuildLoopCount% subgroups
342 for /l %%G in (1, 1, %__BuildLoopCount%) do (
344 set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%";Append=!__AppendToLog!
345 set __MsbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%";Append=!__AppendToLog!
346 set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%";Append=!__AppendToLog!
348 set TestBuildSlice=%%G
349 echo Running: msbuild %__ProjectDir%\tests\build.proj !__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! %TargetsWindowsMsbuildArg% %__msbuildArgs% %__BuildAgainstPackagesArg% !__PriorityArg! %__UnprocessedBuildArgs%
351 call msbuild %__ProjectDir%\tests\build.proj !__MsbuildLog! !__MsbuildWrn! !__MsbuildErr! %TargetsWindowsMsbuildArg% %__msbuildArgs% %__BuildAgainstPackagesArg% !__PriorityArg! %__UnprocessedBuildArgs%
354 echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
358 REM This is necessary because of a(n apparent) bug in the FOR /L command. Under certain circumstances,
359 REM such as when this script is invoke with CMD /C "build-test.cmd", a non-zero exit directly from
360 REM within the loop body will not propagate to the caller. For some reason, goto works around it.
364 set __SkipPackageRestore=true
365 set __SkipTargetingPackBuild=true
366 set __AppendToLog=true
369 REM Check that we've built about as many tests as we expect. This is primarily intended to prevent accidental changes that cause us to build
370 REM drastically fewer Pri-1 tests than expected.
371 echo %__MsgPrefix%Check the managed tests build
372 echo Running: msbuild %__ProjectDir%\tests\runtest.proj /t:CheckTestBuild /p:CLRTestPriorityToBuild=%__Priority% %__msbuildArgs% %__unprocessedBuildArgs%
373 call msbuild %__ProjectDir%\tests\runtest.proj /t:CheckTestBuild /p:CLRTestPriorityToBuild=%__Priority% %__msbuildArgs% %__unprocessedBuildArgs%
375 echo %__MsgPrefix%Error: build failed.
381 REM =========================================================================================
383 REM === Prepare the test drop
385 REM =========================================================================================
387 echo %__MsgPrefix%Removing 'ni' files and 'lock' folders from %__TestBinDir%
388 REM Remove any NI from previous runs.
389 powershell -NoProfile "Get-ChildItem -path %__TestBinDir% -Include '*.ni.*' -Recurse -Force | Remove-Item -force"
390 REM Remove any lock folder used for synchronization from previous runs.
391 powershell -NoProfile "Get-ChildItem -path %__TestBinDir% -Include 'lock' -Recurse -Force | where {$_.Attributes -eq 'Directory'}| Remove-Item -force -Recurse"
393 set CORE_ROOT=%__TestBinDir%\Tests\Core_Root
394 set CORE_ROOT_STAGE=%__TestBinDir%\Tests\Core_Root_Stage
395 if exist "%CORE_ROOT%" rd /s /q "%CORE_ROOT%"
396 if exist "%CORE_ROOT_STAGE%" rd /s /q "%CORE_ROOT_STAGE%"
398 md "%CORE_ROOT_STAGE%"
399 xcopy "%__BinDir%" "%CORE_ROOT_STAGE%"
401 if defined __BuildAgainstPackagesArg (
402 if "%__TargetsWindows%"=="0" (
404 if not exist %__PackagesDir%\TestNativeBins (
405 echo %__MsgPrefix%Error: Ensure you have run sync.cmd -ab before building a non-Windows test overlay against packages
409 for /R %__PackagesDir%\TestNativeBins\%__RuntimeId%\%__BuildType% %%f in (*.so) do copy %%f %CORE_ROOT_STAGE%
410 for /R %__PackagesDir%\TestNativeBins\%__RuntimeId%\%__BuildType% %%f in (*.dylib) do copy %%f %CORE_ROOT_STAGE%
414 REM =========================================================================================
416 REM === Create the test overlay
418 REM =========================================================================================
420 echo %__MsgPrefix%Creating test overlay
423 if defined __RuntimeId (
424 set RuntimeIdArg=/p:RuntimeId="%__RuntimeId%"
427 set __BuildLogRootName=Tests_Overlay_Managed
428 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
429 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
430 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
431 set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
432 set __MsbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
433 set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
434 set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
436 call %__ProjectDir%\msbuild.cmd /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^
437 /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^
438 /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^
439 /p:UsePartialNGENOptimization=false /maxcpucount^
440 %__ProjectDir%\tests\runtest.proj /t:CreateTestOverlay^
441 !__Logging! %__CommonMSBuildArgs% %RuntimeIdArg% %__PriorityArg% %__UnprocessedBuildArgs%
443 echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
450 xcopy /s /y "%CORE_ROOT_STAGE%" "%CORE_ROOT%"
452 REM =========================================================================================
454 REM === Create the test host necessary for running CoreFX tests.
455 REM === The test host includes a dotnet executable, system libraries and CoreCLR assemblies found in CORE_ROOT.
457 REM =========================================================================================
459 echo %__MsgPrefix%Building CoreFX test host
461 set __BuildLogRootName=Tests_CoreFX_Testhost
462 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
463 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
464 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
465 set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
466 set __MsbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
467 set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
468 set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
470 call %__ProjectDir%\msbuild.cmd /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^
471 /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^
472 /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^
473 /p:UsePartialNGENOptimization=false /maxcpucount^
474 %__ProjectDir%\tests\runtest.proj /t:CreateTestHost^
475 !__Logging! %__CommonMSBuildArgs% %RuntimeIdArg% %__PriorityArg% %__UnprocessedBuildArgs%
477 echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
484 REM =========================================================================================
486 REM === Create test wrappers.
488 REM =========================================================================================
490 if defined __SkipManaged goto SkipBuildingWrappers
492 echo %__MsgPrefix%Creating test wrappers
494 set __BuildLogRootName=Tests_XunitWrapper
495 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
496 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
497 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
498 set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
499 set __MsbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
500 set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
501 set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
503 REM Build wrappers using the local SDK's msbuild. As we move to arcade, the other builds should be moved away from run.exe as well.
504 call %DotNetCli% msbuild %__ProjectDir%\tests\runtest.proj /p:RestoreAdditionalProjectSources=https://dotnet.myget.org/F/dotnet-core/ /p:BuildWrappers=true !__Logging! %__msbuildArgs% %TargetsWindowsMsbuildArg% %__BuildAgainstPackagesArg% %__UnprocessedBuildArgs%
506 echo %__MsgPrefix%Error: Xunit wrapper build failed. Refer to the build log files for details:
513 echo { "build_os": "%__BuildOS%", "build_arch": "%__BuildArch%", "build_type": "%__BuildType%" } > "%__TestBinDir%/build_info.json"
515 :SkipBuildingWrappers
517 REM =========================================================================================
519 REM === Crossgen assemblies if needed.
521 REM =========================================================================================
523 set __CrossgenArg = ""
524 if defined __DoCrossgen (
525 set __CrossgenArg="/p:Crossgen=true"
526 if "%__TargetsWindows%" == "1" (
527 echo %__MsgPrefix%Running crossgen on framework assemblies
530 echo "%__MsgPrefix%Crossgen only supported on Windows, for now"
534 rd /s /q "%CORE_ROOT_STAGE%"
536 REM =========================================================================================
538 REM === Prep test binaries for Helix publishing
540 REM =========================================================================================
542 if not defined __ZipTests goto SkipPrepForPublish
544 echo %__MsgPrefix%Preparing test binaries for Helix publishing
546 set __BuildLogRootName=Helix_Prep
547 set __BuildLog=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.log
548 set __BuildWrn=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn
549 set __BuildErr=%__LogsDir%\%__BuildLogRootName%_%__BuildOS%__%__BuildArch%__%__BuildType%.err
550 set __MsbuildLog=/flp:Verbosity=normal;LogFile="%__BuildLog%"
551 set __MsbuildWrn=/flp1:WarningsOnly;LogFile="%__BuildWrn%"
552 set __MsbuildErr=/flp2:ErrorsOnly;LogFile="%__BuildErr%"
553 set __Logging=!__MsbuildLog! !__MsbuildWrn! !__MsbuildErr!
555 call %__ProjectDir%\msbuild.cmd /nologo /verbosity:minimal /clp:Summary /nodeReuse:false^
556 /l:BinClashLogger,Tools/net46/Microsoft.DotNet.Build.Tasks.dll;LogFile=binclash.log^
557 /p:RestoreDefaultOptimizationDataPackage=false /p:PortableBuild=true^
558 /p:UsePartialNGENOptimization=false /maxcpucount^
559 %__ProjectDir%\tests\helixprep.proj^
560 !__Logging! %__CommonMSBuildArgs% %RuntimeIdArg% %TargetsWindowsMSBuildArg% %__CrossgenArg% %__PriorityArg% %__UnprocessedBuildArgs%
562 echo %__MsgPrefix%Error: build failed. Refer to the build log files for details:
571 REM =========================================================================================
573 REM === All builds complete!
575 REM =========================================================================================
577 echo %__MsgPrefix%Test build succeeded. Finished at %TIME%
578 echo %__MsgPrefix%Test binaries are available at !__TestBinDir!
583 echo Build the CoreCLR tests.
586 echo %0 [option1] [option2] ...
587 echo All arguments are optional. Options are case-insensitive. The options are:
589 echo.-? -h -help --help: view this message.
590 echo Build architecture: one of x64, x86, arm, arm64 ^(default: x64^).
591 echo Build type: one of Debug, Checked, Release ^(default: Debug^).
592 echo skipmanaged: skip the managed tests build
593 echo skipnative: skip the native tests build
594 echo buildtesthostonly: build the CoreFX testhost only
595 echo buildagainstpackages: builds tests against restored packages, instead of against a built product.
596 echo skiprestorepackages: skip package restore
597 echo runtimeid ^<ID^>: Builds a test overlay for the specified OS ^(Only supported when building against packages^). Supported IDs are:
598 echo alpine.3.4.3-x64: Builds overlay for Alpine 3.4.3
599 echo debian.8-x64: Builds overlay for Debian 8
600 echo fedora.24-x64: Builds overlay for Fedora 24
601 echo linux-x64: Builds overlay for portable linux
602 echo opensuse.42.1-x64: Builds overlay for OpenSUSE 42.1
603 echo osx.10.12-x64: Builds overlay for OSX 10.12
604 echo osx-x64: Builds overlay for portable OSX
605 echo rhel.7-x64: Builds overlay for RHEL 7 or CentOS
606 echo ubuntu.14.04-x64: Builds overlay for Ubuntu 14.04
607 echo ubuntu.16.04-x64: Builds overlay for Ubuntu 16.04
608 echo ubuntu.16.10-x64: Builds overlay for Ubuntu 16.10
609 echo win-x64: Builds overlay for portable Windows
610 echo win7-x64: Builds overlay for Windows 7
611 echo ziptests: zips CoreCLR tests and Core_Root for a Helix run
612 echo crossgen: Precompiles the framework managed assemblies
613 echo targetsNonWindows:
614 echo Exclude- Optional parameter - specify location of default exclusion file ^(defaults to tests\issues.targets if not specified^)
615 echo Set to "" to disable default exclusion file.
616 echo -- ... : all arguments following this tag will be passed directly to msbuild.
617 echo -priority=^<N^> : specify a set of tests that will be built and run, with priority N.
618 echo 0: Build only priority 0 cases as essential testcases (default)
619 echo 1: Build all tests with priority 0 and 1
620 echo 666: Build all tests with priority 0, 1 ... 666
621 echo -verbose: enables detailed file logging for the msbuild tasks into the msbuild log file.
625 echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
626 This is due to a bug in the Visual Studio installer. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
627 at the install location of previous Visual Studio version. The workaround is to copy the DIA SDK folder from the Visual Studio install location ^
628 of the previous version to "%VSINSTALLDIR%" and then build.
629 REM DIA SDK not included in Express editions
630 echo Visual Studio Express does not include the DIA SDK. ^
631 You need Visual Studio 2015 or 2017 (Community is free).
632 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
636 for %%F in (%CORE_ROOT%\*.dll) do call :PrecompileAssembly "%%F" %%~nF%%~xF
639 REM Compile the managed assemblies in Core_ROOT before running the tests
642 REM Skip mscorlib since it is already precompiled.
643 if /I "%2" == "mscorlib.dll" exit /b 0
644 if /I "%2" == "mscorlib.ni.dll" exit /b 0
645 REM don't precompile anything from CoreCLR
646 if /I exist %CORE_ROOT_STAGE%\%2 exit /b 0
648 "%CORE_ROOT_STAGE%\crossgen.exe" /Platform_Assemblies_Paths "%CORE_ROOT%" /in "%1" /out "%CORE_ROOT%/temp.ni.dll" >nul 2>nul
649 set /a __exitCode = %errorlevel%
650 if "%__exitCode%" == "-2146230517" (
651 echo %2 is not a managed assembly.
655 if %__exitCode% neq 0 (
656 echo Unable to precompile %2
660 REM Delete original .dll & replace it with the Crossgened .dll
662 ren "%CORE_ROOT%\temp.ni.dll" %2
664 echo Successfully precompiled %2