1 @if not defined __echo @echo off
2 setlocal EnableDelayedExpansion EnableExtensions
4 set __ThisScriptShort=%0
5 set __ThisScriptFull="%~f0"
6 set __ThisScriptPath="%~dp0"
8 :: Note that the msbuild project files (specifically, dir.proj) will use the following variables, if set:
9 :: __BuildArch -- default: x64
10 :: __BuildType -- default: Debug
11 :: __BuildOS -- default: Windows_NT
12 :: __ProjectDir -- default: directory of the dir.props file
13 :: __SourceDir -- default: %__ProjectDir%\src\
14 :: __PackagesDir -- default: %__ProjectDir%\packages\
15 :: __RootBinDir -- default: %__ProjectDir%\bin\
16 :: __BinDir -- default: %__RootBinDir%\%__BuildOS%.%__BuildArch.%__BuildType%\
18 :: __PackagesBinDir -- default: %__BinDir%\.nuget
19 :: __TestWorkingDir -- default: %__RootBinDir%\tests\%__BuildOS%.%__BuildArch.%__BuildType%\
21 :: Thus, these variables are not simply internal to this script!
23 :: Set the default arguments for build
26 set __BuildOS=Windows_NT
28 :: Default to highest Visual Studio version available
29 set __VSVersion=vs2015
31 if defined VS140COMNTOOLS set __VSVersion=vs2015
33 :: Define a prefix for most output progress messages that come from this script. That makes
34 :: it easier to see where these are coming from. Note that there is a trailing space here.
35 set __MsgPrefix=BUILD:
37 :: Set the various build properties here so that CMake and MSBuild can pick them up
38 set "__ProjectDir=%~dp0"
39 :: remove trailing slash
40 if %__ProjectDir:~-1%==\ set "__ProjectDir=%__ProjectDir:~0,-1%"
41 set "__ProjectFilesDir=%__ProjectDir%"
42 set "__SourceDir=%__ProjectDir%\src"
43 set "__PackagesDir=%__ProjectDir%\packages"
44 set "__RootBinDir=%__ProjectDir%\bin"
45 set "__LogsDir=%__RootBinDir%\Logs"
51 set __SkipCoreLibBuild=
52 set __SkipNativeBuild=
54 set __BuildSequential=
56 set __SkipBuildPackages=
57 set __msbuildCleanBuildArgs=
58 set __msbuildExtraArgs=
60 set __OfficialBuildIdArg=
67 set __BuildArchArm64=0
69 set __BuildTypeDebug=0
70 set __BuildTypeChecked=0
71 set __BuildTypeRelease=0
72 set __BuildJit32="-DBUILD_JIT32=0"
74 REM __PassThroughArgs is a set of things that will be passed through to nested calls to build.cmd
76 set __PassThroughArgs=
79 if "%1" == "" goto ArgsDone
81 if /i "%1" == "/?" goto Usage
82 if /i "%1" == "-?" goto Usage
83 if /i "%1" == "/h" goto Usage
84 if /i "%1" == "-h" goto Usage
85 if /i "%1" == "/help" goto Usage
86 if /i "%1" == "-help" goto Usage
88 if /i "%1" == "all" (set __BuildAll=1&shift&goto Arg_Loop)
90 if /i "%1" == "x64" (set __BuildArchX64=1&shift&goto Arg_Loop)
91 if /i "%1" == "x86" (set __BuildArchX86=1&shift&goto Arg_Loop)
92 if /i "%1" == "arm" (set __BuildArchArm=1&shift&goto Arg_Loop)
93 if /i "%1" == "arm64" (set __BuildArchArm64=1&shift&goto Arg_Loop)
95 if /i "%1" == "debug" (set __BuildTypeDebug=1&shift&goto Arg_Loop)
96 if /i "%1" == "checked" (set __BuildTypeChecked=1&shift&goto Arg_Loop)
97 if /i "%1" == "release" (set __BuildTypeRelease=1&shift&goto Arg_Loop)
99 REM All arguments after this point will be passed through directly to build.cmd on nested invocations
100 REM using the "all" argument, and must be added to the __PassThroughArgs variable.
101 set __PassThroughArgs=%__PassThroughArgs% %1
103 if /i "%1" == "clean" (set __CleanBuild=1&shift&goto Arg_Loop)
105 if /i "%1" == "freebsdmscorlib" (set __CoreLibOnly=1&set __BuildOS=FreeBSD&shift&goto Arg_Loop)
106 if /i "%1" == "linuxmscorlib" (set __CoreLibOnly=1&set __BuildOS=Linux&shift&goto Arg_Loop)
107 if /i "%1" == "netbsdmscorlib" (set __CoreLibOnly=1&set __BuildOS=NetBSD&shift&goto Arg_Loop)
108 if /i "%1" == "osxmscorlib" (set __CoreLibOnly=1&set __BuildOS=OSX&shift&goto Arg_Loop)
109 if /i "%1" == "windowsmscorlib" (set __CoreLibOnly=1&set __BuildOS=Windows_NT&shift&goto Arg_Loop)
111 if /i "%1" == "vs2015" (set __VSVersion=%1&shift&goto Arg_Loop)
112 if /i "%1" == "configureonly" (set __ConfigureOnly=1&set __SkipCoreLibBuild=1&set __SkipTestBuild=1&shift&goto Arg_Loop)
113 if /i "%1" == "skipconfigure" (set __SkipConfigure=1&shift&goto Arg_Loop)
114 if /i "%1" == "skipmscorlib" (set __SkipCoreLibBuild=1&shift&goto Arg_Loop)
115 if /i "%1" == "skipnative" (set __SkipNativeBuild=1&shift&goto Arg_Loop)
116 if /i "%1" == "skiptests" (set __SkipTestBuild=1&shift&goto Arg_Loop)
117 if /i "%1" == "skiprestore" (set __SkipRestore=1&shift&goto Arg_Loop)
118 if /i "%1" == "skipbuildpackages" (set __SkipBuildPackages=1&shift&goto Arg_Loop)
119 if /i "%1" == "sequential" (set __BuildSequential=1&shift&goto Arg_Loop)
120 if /i "%1" == "disableoss" (set __SignTypeReal="/p:SignType=real"&shift&goto Arg_Loop)
121 if /i "%1" == "priority" (set __TestPriority=%2&set __PassThroughArgs=%__PassThroughArgs% %2&shift&shift&goto Arg_Loop)
122 if /i "%1" == "buildjit32" (set __BuildJit32="-DBUILD_JIT32=1"&shift&goto Arg_Loop)
124 @REM For backwards compatibility, continue accepting "skiptestbuild", which was the original name of the option.
125 if /i "%1" == "skiptestbuild" (set __SkipTestBuild=1&shift&goto Arg_Loop)
127 @REM It was initially /toolset_dir. Not sure why, since it doesn't match the other usage.
128 if /i "%1" == "/toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&shift&shift&goto Arg_Loop)
129 if /i "%1" == "toolset_dir" (set __ToolsetDir=%2&set __PassThroughArgs=%__PassThroughArgs% %2&shift&shift&goto Arg_Loop)
131 if /i not "%1" == "msbuildargs" goto SkipMsbuildArgs
132 :: All the rest of the args will be collected and passed directly to msbuild.
135 if "%1"=="" goto ArgsDone
136 if /i [%1] == [/p:OfficialBuildId] (
138 echo Error: /p:OfficialBuildId arg should have a value
141 set __OfficialBuildIdArg=/p:OfficialBuildId=%2
143 goto CollectMsbuildArgs
145 set __msbuildExtraArgs=%__msbuildExtraArgs% %1
146 set __PassThroughArgs=%__PassThroughArgs% %1
147 goto CollectMsbuildArgs
150 echo Invalid command-line argument: %1
155 if defined __ConfigureOnly if defined __SkipConfigure (
156 echo "Error: option 'configureonly' is incompatible with 'skipconfigure'"
160 if defined __SkipCoreLibBuild if defined __CoreLibOnly (
161 echo Error: option 'skipmscorlib' is incompatible with 'freebsdmscorlib', 'linuxmscorlib', 'netbsdmscorlib', 'osxmscorlib' and 'windowsmscorlib'.
165 if defined __BuildAll goto BuildAll
167 set /A __TotalSpecifiedBuildArch=__BuildArchX64 + __BuildArchX86 + __BuildArchArm + __BuildArchArm64
168 if %__TotalSpecifiedBuildArch% GTR 1 (
169 echo Error: more than one build architecture specified, but "all" not specified.
173 if %__BuildArchX64%==1 set __BuildArch=x64
174 if %__BuildArchX86%==1 set __BuildArch=x86
175 if %__BuildArchArm%==1 set __BuildArch=arm
176 if %__BuildArchArm64%==1 (
177 set __BuildArch=arm64
181 set /A __TotalSpecifiedBuildType=__BuildTypeDebug + __BuildTypeChecked + __BuildTypeRelease
182 if %__TotalSpecifiedBuildType% GTR 1 (
183 echo Error: more than one build type specified, but "all" not specified.
187 if %__BuildTypeDebug%==1 set __BuildType=Debug
188 if %__BuildTypeChecked%==1 set __BuildType=Checked
189 if %__BuildTypeRelease%==1 set __BuildType=Release
191 echo %__MsgPrefix%Commencing CoreCLR Repo build
193 :: Set the remaining variables based upon the determined build configuration
194 set "__BinDir=%__RootBinDir%\Product\%__BuildOS%.%__BuildArch%.%__BuildType%"
195 set "__IntermediatesDir=%__RootBinDir%\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
196 set "__PackagesBinDir=%__BinDir%\.nuget"
197 set "__TestRootDir=%__RootBinDir%\tests"
198 set "__TestBinDir=%__TestRootDir%\%__BuildOS%.%__BuildArch%.%__BuildType%"
199 set "__TestIntermediatesDir=%__RootBinDir%\tests\obj\%__BuildOS%.%__BuildArch%.%__BuildType%"
200 set "__CrossComponentBinDir=%__BinDir%"
201 if defined __CrossArch set __CrossComponentBinDir=%__CrossComponentBinDir%\%__CrossArch%
203 :: Generate path to be set for CMAKE_INSTALL_PREFIX to contain forward slash
204 set "__CMakeBinDir=%__BinDir%"
205 set "__CMakeBinDir=%__CMakeBinDir:\=/%"
207 :: Configure environment if we are doing a clean build.
208 if not defined __CleanBuild goto SkipCleanBuild
209 echo %__MsgPrefix%Doing a clean build
211 :: MSBuild projects would need a rebuild
212 set __msbuildCleanBuildArgs=/t:rebuild
214 :: Cleanup the previous output for the selected configuration
215 if exist "%__BinDir%" rd /s /q "%__BinDir%"
216 if exist "%__IntermediatesDir%" rd /s /q "%__IntermediatesDir%"
217 if exist "%__TestBinDir%" rd /s /q "%__TestBinDir%"
218 if exist "%__TestIntermediatesDir%" rd /s /q "%__TestIntermediatesDir%"
219 if exist "%__LogsDir%" del /f /q "%__LogsDir%\*_%__BuildOS%__%__BuildArch%__%__BuildType%.*"
220 if exist "%__ProjectDir%\Tools" rd /s /q "%__ProjectDir%\Tools"
224 if not exist "%__BinDir%" md "%__BinDir%"
225 if not exist "%__IntermediatesDir%" md "%__IntermediatesDir%"
226 if not exist "%__LogsDir%" md "%__LogsDir%"
228 :: CMake isn't a requirement when building CoreLib only
229 if defined __CoreLibOnly goto CheckVS
231 echo %__MsgPrefix%Checking prerequisites
233 :: Validate that PowerShell is accessibile.
234 for %%X in (powershell.exe) do (set __PSDir=%%~$PATH:X)
235 if not defined __PSDir goto :NoPS
237 :: Validate Powershell version
238 set "PS_VERSION_LOG=%__LogsDir%\ps-version.log"
239 powershell -NoProfile -ExecutionPolicy unrestricted -Command "$PSVersionTable.PSVersion.Major" > %PS_VERSION_LOG%
240 set /P PS_VERSION=< %PS_VERSION_LOG%
241 if %PS_VERSION% LEQ 2 (
245 :: Eval the output from probe-win1.ps1
246 for /f "delims=" %%a in ('powershell -NoProfile -ExecutionPolicy RemoteSigned "& ""%__SourceDir%\pal\tools\probe-win.ps1"""') do %%a
250 set __VSProductVersion=
251 if /i "%__VSVersion%" == "vs2015" set __VSProductVersion=140
253 :: Check presence of VS
254 if not defined VS%__VSProductVersion%COMNTOOLS goto NoVS
256 set __VSToolsRoot=!VS%__VSProductVersion%COMNTOOLS!
257 if %__VSToolsRoot:~-1%==\ set "__VSToolsRoot=%__VSToolsRoot:~0,-1%"
259 :: Does VS really exist?
260 if not exist "%__VSToolsRoot%\..\IDE\devenv.exe" goto NoVS
261 if not exist "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" goto NoVS
262 if not exist "%__VSToolsRoot%\VsDevCmd.bat" goto NoVS
265 set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
267 if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
268 if not exist %_msbuildexe% echo %__MsgPrefix%Error: Could not find MSBuild.exe. Please see https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md for build instructions. && exit /b 1
270 :: Note: We've disabled node reuse because it causes file locking issues.
271 :: The issue is that we extend the build with our own targets which
272 :: means that that rebuilding cannot successfully delete the task
274 set __msbuildCommonArgs=/nologo /nodeReuse:false %__msbuildCleanBuildArgs% %__msbuildExtraArgs%
276 if not defined __BuildSequential (
277 set __msbuildCommonArgs=%__msbuildCommonArgs% /maxcpucount
279 if defined __SkipRestore (
280 set __msbuildCommonArgs=%__msbuildCommonArgs% /p:RestoreDuringBuild=false
284 REM =========================================================================================
286 REM === Restore Build Tools
288 REM =========================================================================================
289 call %__ThisScriptPath%init-tools.cmd
291 echo ERROR: Could not restore build tools.
295 REM =========================================================================================
297 REM === Start the build steps
299 REM =========================================================================================
301 :: Generate _version.h
302 if exist "%__RootBinDir%\obj\_version.h" del "%__RootBinDir%\obj\_version.h"
303 %_msbuildexe% "%__ProjectFilesDir%\build.proj" /t:GenerateVersionHeader /v:minimal /p:NativeVersionHeaderFile="%__RootBinDir%\obj\_version.h" /p:GenerateVersionHeader=true %__OfficialBuildIdArg%
304 if defined __CoreLibOnly goto PerformCoreLibBuild
306 if defined __SkipNativeBuild (
307 echo %__MsgPrefix%Skipping native components build
311 echo %__MsgPrefix%Commencing build of native components for %__BuildOS%.%__BuildArch%.%__BuildType%
313 REM Use setlocal to restrict environment changes form vcvarsall.bat and more to just this native components build section.
314 setlocal EnableDelayedExpansion EnableExtensions
316 if /i "%__BuildArch%" == "arm64" (
317 rem arm64 builds currently use private toolset which has not been released yet
318 REM TODO, remove once the toolset is open.
324 :: Set the environment for the native build
325 set __VCBuildArch=x86_amd64
326 if /i "%__BuildArch%" == "x86" (set __VCBuildArch=x86)
327 echo %__MsgPrefix%Using environment: "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" %__VCBuildArch%
328 call "%__VSToolsRoot%\..\..\VC\vcvarsall.bat" %__VCBuildArch%
329 @if defined __echo @echo on
331 if not defined VSINSTALLDIR (
332 echo %__MsgPrefix%Error: VSINSTALLDIR variable not defined.
335 if not exist "%VSINSTALLDIR%DIA SDK" goto NoDIA
339 if defined __SkipConfigure goto SkipConfigure
341 echo %__MsgPrefix%Regenerating the Visual Studio solution
343 pushd "%__IntermediatesDir%"
344 call "%__SourceDir%\pal\tools\gen-buildsys-win.bat" "%__ProjectDir%" %__VSVersion% %__BuildArch% %__BuildJit32%
345 @if defined __echo @echo on
350 if not exist "%__IntermediatesDir%\install.vcxproj" (
351 echo %__MsgPrefix%Error: failed to generate native component build project!
355 REM =========================================================================================
357 REM === Build the CLR VM
359 REM =========================================================================================
361 if defined __ConfigureOnly goto SkipNativeBuild
363 echo %__MsgPrefix%Invoking msbuild
365 set "__BuildLog=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
366 set "__BuildWrn=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
367 set "__BuildErr=%__LogsDir%\CoreCLR_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
368 set __msbuildLogArgs=^
369 /fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%" ^
370 /fileloggerparameters1:WarningsOnly;LogFile="%__BuildWrn%" ^
371 /fileloggerparameters2:ErrorsOnly;LogFile="%__BuildErr%" ^
372 /consoleloggerparameters:Summary ^
375 set __msbuildArgs="%__IntermediatesDir%\install.vcxproj" %__msbuildCommonArgs% %__msbuildLogArgs% /p:Configuration=%__BuildType%
377 if /i "%__BuildArch%" == "arm64" (
378 REM TODO, remove once we have msbuild support for this platform.
379 set __msbuildArgs=%__msbuildArgs% /p:UseEnv=true
381 set __msbuildArgs=%__msbuildArgs% /p:Platform=%__BuildArch%
384 %_msbuildexe% %__msbuildArgs%
386 echo %__MsgPrefix%Error: native component build failed. Refer to the build log files for details:
393 REM endlocal to rid us of environment changes from vcvarsall.bat
398 REM =========================================================================================
400 REM === CoreLib and NuGet package build section.
402 REM =========================================================================================
406 REM setlocal to prepare for vsdevcmd.bat
407 setlocal EnableDelayedExpansion EnableExtensions
409 rem Explicitly set Platform causes conflicts in CoreLib project files. Clear it to allow building from VS x64 Native Tools Command Prompt
412 :: Set the environment for the managed build
413 echo %__MsgPrefix%Using environment: "%__VSToolsRoot%\VsDevCmd.bat"
414 call "%__VSToolsRoot%\VsDevCmd.bat"
416 if defined __SkipCoreLibBuild (
417 echo %__MsgPrefix%Skipping System.Private.CoreLib build
418 goto SkipCoreLibBuild
421 echo %__MsgPrefix%Commencing build of System.Private.CoreLib for %__BuildOS%.%__BuildArch%.%__BuildType%
423 set "__BuildLog=%__LogsDir%\System.Private.CoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
424 set "__BuildWrn=%__LogsDir%\System.Private.CoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
425 set "__BuildErr=%__LogsDir%\System.Private.CoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
426 set __msbuildLogArgs=^
427 /fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%" ^
428 /fileloggerparameters1:WarningsOnly;LogFile="%__BuildWrn%" ^
429 /fileloggerparameters2:ErrorsOnly;LogFile="%__BuildErr%" ^
430 /consoleloggerparameters:Summary ^
433 set __msbuildArgs="%__ProjectFilesDir%\build.proj" %__msbuildCommonArgs% %__msbuildLogArgs% %__SignTypeReal%
435 set __BuildNugetPackage=true
436 if defined __CoreLibOnly set __BuildNugetPackage=false
437 if /i "%__BuildArch%" =="arm64" set __BuildNugetPackage=false
438 if %__BuildNugetPackage%==false set __msbuildArgs=%__msbuildArgs% /p:BuildNugetPackage=false
440 %_msbuildexe% %__msbuildArgs%
442 echo %__MsgPrefix%Error: System.Private.CoreLib build failed. Refer to the build log files for details:
449 if defined __CoreLibOnly (
450 echo %__MsgPrefix%System.Private.CoreLib successfully built.
454 echo %__MsgPrefix%Generating native image of System.Private.CoreLib for %__BuildOS%.%__BuildArch%.%__BuildType%
456 set "__CrossGenCoreLibLog=%__LogsDir%\CrossgenCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
457 set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe"
458 "%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\System.Private.CoreLib.ni.dll" "%__BinDir%\System.Private.CoreLib.dll" > "%__CrossGenCoreLibLog%" 2>&1
459 if %errorlevel% NEQ 0 (
460 echo %__MsgPrefix%Error: CrossGen System.Private.CoreLib build failed. Refer to the build log file for details:
461 echo %__CrossGenCoreLibLog%
465 echo %__MsgPrefix%Generating native image of MScorlib facade for %__BuildOS%.%__BuildArch%.%__BuildType%
467 set "__CrossGenCoreLibLog=%__LogsDir%\CrossgenMSCoreLib_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
468 set "__CrossgenExe=%__CrossComponentBinDir%\crossgen.exe"
469 "%__CrossgenExe%" /Platform_Assemblies_Paths "%__BinDir%" /out "%__BinDir%\mscorlib.ni.dll" "%__BinDir%\mscorlib.dll" > "%__CrossGenCoreLibLog%" 2>&1
470 if %errorlevel% NEQ 0 (
471 echo %__MsgPrefix%Error: CrossGen mscorlib facade build failed. Refer to the build log file for details:
472 echo %__CrossGenCoreLibLog%
479 if /i "%__BuildArch%" =="arm64" goto :SkipNuget
480 if /i "%__SkipBuildPackages%" == 1 goto :SkipNuget
482 set "__BuildLog=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.log"
483 set "__BuildWrn=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.wrn"
484 set "__BuildErr=%__LogsDir%\Nuget_%__BuildOS%__%__BuildArch%__%__BuildType%.err"
485 set __msbuildLogArgs=^
486 /fileloggerparameters:Verbosity=normal;LogFile="%__BuildLog%" ^
487 /fileloggerparameters1:WarningsOnly;LogFile="%__BuildWrn%" ^
488 /fileloggerparameters2:ErrorsOnly;LogFile="%__BuildErr%" ^
489 /consoleloggerparameters:Summary ^
492 REM The conditions as to what to build are captured in the builds file.
493 set __msbuildArgs="%__ProjectFilesDir%\src\.nuget\packages.builds" /p:Platform=%__BuildArch%
494 %_msbuildexe% !__msbuildArgs! %__msbuildLogArgs%
496 echo %__MsgPrefix%Error: Nuget package generation failed build failed. Refer to the build log files for details:
506 REM endlocal to rid us of environment changes from vsdevenv.bat
509 REM =========================================================================================
511 REM === Test build section
513 REM =========================================================================================
515 if defined __SkipTestBuild (
516 echo %__MsgPrefix%Skipping test build
520 echo %__MsgPrefix%Commencing build of tests for %__BuildOS%.%__BuildArch%.%__BuildType%
522 REM Construct the arguments to pass to the test build script.
524 set __BuildtestArgs=%__BuildArch% %__BuildType% %__VSVersion%
526 if defined __CleanBuild (
527 set "__BuildtestArgs=%__BuildtestArgs% clean"
530 if defined __BuildSequential (
531 set "__BuildtestArgs=%__BuildtestArgs% sequential"
534 if defined __TestPriority (
535 set "__BuildtestArgs=%__BuildtestArgs% Priority %__TestPriority%"
538 rem arm64 builds currently use private toolset which has not been released yet
539 REM TODO, remove once the toolset is open.
540 if /i "%__BuildArch%" == "arm64" call :PrivateToolSet
542 call %__ProjectDir%\tests\buildtest.cmd %__BuildtestArgs%
545 REM buildtest.cmd has already emitted an error message and mentioned the build log file to examine.
551 REM =========================================================================================
553 REM === All builds complete!
555 REM =========================================================================================
557 echo %__MsgPrefix%Repo successfully built.
558 echo %__MsgPrefix%Product binaries are available at !__BinDir!
559 if not defined __SkipTestBuild (
560 echo %__MsgPrefix%Test binaries are available at !__TestBinDir!
564 REM =========================================================================================
566 REM === Handle the "all" case.
568 REM =========================================================================================
574 set /A __TotalSpecifiedBuildArch=__BuildArchX64 + __BuildArchX86 + __BuildArchArm + __BuildArchArm64
575 if %__TotalSpecifiedBuildArch% EQU 0 (
576 REM Nothing specified means we want to build all architectures.
577 set __BuildArchList=x64 x86 arm arm64
580 REM Otherwise, add all the specified architectures to the list.
582 if %__BuildArchX64%==1 set __BuildArchList=%__BuildArchList% x64
583 if %__BuildArchX86%==1 set __BuildArchList=%__BuildArchList% x86
584 if %__BuildArchArm%==1 set __BuildArchList=%__BuildArchList% arm
585 if %__BuildArchArm64%==1 set __BuildArchList=%__BuildArchList% arm64
589 set /A __TotalSpecifiedBuildType=__BuildTypeDebug + __BuildTypeChecked + __BuildTypeRelease
590 if %__TotalSpecifiedBuildType% EQU 0 (
591 REM Nothing specified means we want to build all build types.
592 set __BuildTypeList=Debug Checked Release
595 if %__BuildTypeDebug%==1 set __BuildTypeList=%__BuildTypeList% Debug
596 if %__BuildTypeChecked%==1 set __BuildTypeList=%__BuildTypeList% Checked
597 if %__BuildTypeRelease%==1 set __BuildTypeList=%__BuildTypeList% Release
599 REM Create a temporary file to collect build results. We always build all flavors specified, and
600 REM report a summary of the results at the end.
602 set __AllBuildSuccess=true
603 set __BuildResultFile=%TEMP%\build-all-summary-%RANDOM%.txt
604 if exist %__BuildResultFile% del /f /q %__BuildResultFile%
606 for %%i in (%__BuildArchList%) do (
607 for %%j in (%__BuildTypeList%) do (
608 call :BuildOne %%i %%j
612 if %__AllBuildSuccess%==true (
613 echo %__MsgPrefix%All builds succeeded!
616 echo %__MsgPrefix%Builds failed:
617 type %__BuildResultFile%
618 del /f /q %__BuildResultFile%
622 REM This code is unreachable, but leaving it nonetheless, just in case things change.
628 set __NextCmd=call %__ThisScriptFull% %__BuildArch% %__BuildType% %__PassThroughArgs%
629 echo %__MsgPrefix%Invoking: %__NextCmd%
632 echo %__MsgPrefix% %__BuildArch% %__BuildType% %__PassThroughArgs% >> %__BuildResultFile%
633 set __AllBuildSuccess=false
637 REM =========================================================================================
639 REM === Helper routines
641 REM =========================================================================================
645 echo Build the CoreCLR repo.
648 echo %__ThisScriptShort% [option1] [option2] ...
650 echo %__ThisScriptShort% all [option1] [option2] ...
652 echo All arguments are optional. The options are:
654 echo./? -? /h -h /help -help: view this message.
655 echo Build architecture: one of x64, x86, arm, arm64 ^(default: x64^).
656 echo Build type: one of Debug, Checked, Release ^(default: Debug^).
657 echo Visual Studio version: ^(default: VS2015^).
658 echo clean: force a clean build ^(default is to perform an incremental build^).
659 echo msbuildargs ... : all arguments following this tag will be passed directly to msbuild.
660 echo mscorlib version: one of freebsdmscorlib, linuxmscorlib, netbsdmscorlib, osxmscorlib,
661 echo or windowsmscorlib. If one of these is passed, only System.Private.CoreLib is built,
662 echo for the specified platform ^(FreeBSD, Linux, NetBSD, OS X or Windows,
664 echo priority ^<N^> : specify a set of test that will be built and run, with priority N.
665 echo sequential: force a non-parallel build ^(default is to build in parallel
666 echo using all processors^).
667 echo configureonly: skip all builds; only run CMake ^(default: CMake and builds are run^)
668 echo skipconfigure: skip CMake ^(default: CMake is run^)
669 echo skipmscorlib: skip building System.Private.CoreLib ^(default: System.Private.CoreLib is built^).
670 echo skipnative: skip building native components ^(default: native components are built^).
671 echo skiptests: skip building tests ^(default: tests are built^).
672 echo skiprestore: skip restoring packages ^(default: packages are restored during build^).
673 echo skipbuildpackages: skip building nuget packages ^(default: packages are built^).
674 echo disableoss: Disable Open Source Signing for System.Private.CoreLib.
675 echo toolset_dir ^<dir^> : set the toolset directory -- Arm64 use only. Required for Arm64 builds.
677 echo If "all" is specified, then all build architectures and types are built. If, in addition,
678 echo one or more build architectures or types is specified, then only those build architectures
679 echo and types are built.
683 echo -- builds all architectures, and all build types per architecture
685 echo -- builds all build types for x86
686 echo build all x64 x86 Checked Release
687 echo -- builds x64 and x86 architectures, Checked and Release build types for each
691 echo PowerShell v3.0 or later is a prerequisite to build this repository, but it is not accessible.
692 echo Ensure that it is defined in the PATH environment variable.
693 echo Typically it should be %%SYSTEMROOT%%\System32\WindowsPowerShell\v1.0\.
697 echo PowerShell v3.0 or later is a prerequisite to build this repository.
698 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md
699 echo Download via https://www.microsoft.com/en-us/download/details.aspx?id=40855
703 echo Visual Studio 2015+ ^(Community is free^) is a prerequisite to build this repository.
704 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md
708 echo Error: DIA SDK is missing at "%VSINSTALLDIR%DIA SDK". ^
709 This is due to a bug in the Visual Studio installer. It does not install DIA SDK at "%VSINSTALLDIR%" but rather ^
710 at the install location of previous Visual Studio version. The workaround is to copy the DIA SDK folder from the Visual Studio install location ^
711 of the previous version to "%VSINSTALLDIR%" and then build.
712 :: DIA SDK not included in Express editions
713 echo Visual Studio Express does not include the DIA SDK. ^
714 You need Visual Studio 2015+ (Community is free).
715 echo See: https://github.com/dotnet/coreclr/blob/master/Documentation/project-docs/developer-guide.md#prerequisites
720 echo %__MsgPrefix% Setting Up the usage of __ToolsetDir:%__ToolsetDir%
722 if /i "%__ToolsetDir%" == "" (
723 echo %__MsgPrefix%Error: A toolset directory is required for the Arm64 Windows build. Use the toolset_dir argument.
727 set PATH=%__ToolsetDir%\VC_sdk\bin;%PATH%
728 set LIB=%__ToolsetDir%\VC_sdk\lib\arm64;%__ToolsetDir%\sdpublic\sdk\lib\arm64
730 %__ToolsetDir%\VC_sdk\inc;^
731 %__ToolsetDir%\sdpublic\sdk\inc;^
732 %__ToolsetDir%\sdpublic\shared\inc;^
733 %__ToolsetDir%\sdpublic\shared\inc\minwin;^
734 %__ToolsetDir%\sdpublic\sdk\inc\ucrt;^
735 %__ToolsetDir%\sdpublic\sdk\inc\minwin;^
736 %__ToolsetDir%\sdpublic\sdk\inc\mincore;^
737 %__ToolsetDir%\sdpublic\sdk\inc\abi;^
738 %__ToolsetDir%\sdpublic\sdk\inc\clientcore;^
739 %__ToolsetDir%\diasdk\include