2 setlocal EnableDelayedExpansion
3 set __ProjectFilesDir=%~dp0
7 set __VSProductVersion=120
9 :: Default __Exclude to issues.targets
10 set __Exclude=%~dp0\issues.targets
13 if "%1" == "" goto ArgsDone
14 if /i "%1" == "x64" (set __BuildArch=x64&set __MSBuildBuildArch=x64&shift&goto Arg_Loop)
16 if /i "%1" == "debug" (set __BuildType=debug&shift&goto Arg_Loop)
17 if /i "%1" == "release" (set __BuildType=release&shift&goto Arg_Loop)
18 if /i "%1" == "SkipWrapperGeneration" (set __SkipWrapperGeneration=true&shift&goto Arg_Loop)
19 if /i "%1" == "Exclude" (set __Exclude=%2&shift&shift&goto Arg_Loop)
20 if /i "%1" == "TestEnv" (set __TestEnv=%2&shift&shift&goto Arg_Loop)
22 if /i "%1" == "vs2013" (set __VSVersion=%1&set __VSProductVersion=120&shift&goto Arg_Loop)
23 if /i "%1" == "vs2015" (set __VSVersion=%1&set __VSProductVersion=140&shift&goto Arg_Loop)
25 if /i "%1" == "/?" (goto Usage)
30 :: Check prerequisites
32 :: Check presence of VS
33 if defined VS%__VSProductVersion%COMNTOOLS goto CheckMSbuild
34 echo InVisual Studio 2013+ (Community is free) is a pre-requisite to build this repository.
38 if /i "%__VSVersion%" =="vs2015" goto MSBuild14
39 set _msbuildexe="%ProgramFiles(x86)%\MSBuild\12.0\Bin\MSBuild.exe"
40 if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\12.0\Bin\MSBuild.exe"
41 if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
44 set _msbuildexe="%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe"
45 set UseRoslynCompiler=true
47 if not exist %_msbuildexe% set _msbuildexe="%ProgramFiles%\MSBuild\14.0\Bin\MSBuild.exe"
48 if not exist %_msbuildexe% echo Error: Could not find MSBuild.exe. Please see https://github.com/dotnet/corefx/blob/master/Documentation/developer-guide.md for build instructions. && exit /b 1
50 :: Set the environment for the build- Vs cmd prompt
51 call "!VS%__VSProductVersion%COMNTOOLS!\VsDevCmd.bat"
53 if not defined VSINSTALLDIR echo Error: runtest.cmd should be run from a Visual Studio Command Prompt. Please see https://github.com/dotnet/coreclr/blob/master/Documentation/developer-guide.md for build instructions. && exit /b 1
56 if not defined __BuildArch set __BuildArch=x64
57 if not defined __BuildType set __BuildType=debug
58 if not defined __BuildOS set __BuildOS=Windows_NT
59 if not defined __BinDir set __BinDir=%__ProjectFilesDir%..\bin\Product\%__BuildOS%.%__BuildArch%.%__BuildType%
60 if not defined __TestWorkingDir set __TestWorkingDir=%__ProjectFilesDir%..\bin\tests\%__BuildOS%.%__BuildArch%.%__BuildType%
61 if not defined __LogsDir set __LogsDir=%__ProjectFilesDir%..\bin\Logs
63 :: Default global test environmet variables
64 if not defined XunitTestBinBase set XunitTestBinBase=%__TestWorkingDir%\
65 if not defined XunitTestReportDirBase set XunitTestReportDirBase=%XunitTestBinBase%\Reports\
66 if defined Core_Root goto :CheckTestEnv
68 set noCore_RootSet=true
69 set Core_Root=%__BinDir%
72 ::Check if the test Binaries are built
73 if not exist %XunitTestBinBase% echo Error: Ensure the Test Binaries are built and are present at %XunitTestBinBase%, Run - buildtest.cmd %__BuildArch% %__BuildType% to build the tests first. && exit /b 1
74 if "%Core_Root%" == "" echo Error: Ensure you have done a successful build of the Product and Run - runtest BuildArch BuildType {path to product binaries}. && exit /b 1
75 if not exist %Core_Root%\coreclr.dll echo Error: Ensure you have done a successful build of the Product and %Core_Root% contains runtime binaries. && exit /b 1
76 if not "%__Exclude%"=="" (if not exist %__Exclude% echo Error: Exclusion .targets file not found && exit /b 1)
77 if not "%__TestEnv%"=="" (if not exist %__TestEnv% echo Error: Test Environment script not found && exit /b 1)
78 if not exist %__LogsDir% md %__LogsDir%
80 :SkipDefaultCoreRootSetup
81 set __XunitWrapperBuildLog=%__LogsDir%\Tests_XunitWrapper_%__BuildOS%__%__BuildArch%__%__BuildType%.log
82 set __TestRunBuildLog=%__LogsDir%\TestRunResults_%__BuildOS%__%__BuildArch%__%__BuildType%.log
83 set __TestRunHtmlLog=%__LogsDir%\TestRun_%__BuildOS%__%__BuildArch%__%__BuildType%.html
84 set __TestRunXmlLog=%__LogsDir%\TestRun_%__BuildOS%__%__BuildArch%__%__BuildType%.xml
86 echo Core_Root that will be used is: %Core_Root%
87 echo Starting The Test Run ...
88 if "%__SkipWrapperGeneration%"=="true" goto :preptests
90 :: Log build command line
92 set _buildpostfix=^> "%__TestRunBuildLog%"
94 call :PerformXunitWrapperBuild
100 call :PerformXunitWrapperBuild
102 echo XunitWrapperBuild build failed. Refer %__XunitWrapperBuildLog% for details.
106 :: Log build command line
107 set _buildprefix=echo
108 set _buildpostfix=^> "%__TestRunBuildLog%"
116 if not "%noCore_RootSet%"=="true" goto :runtests
117 set Core_Root=%XunitTestBinBase%\Tests\Core_Root
118 echo Using Default Core_Root as %Core_Root%
119 echo Copying Built binaries from %__BinDir% to %Core_Root%
120 if exist %Core_Root% rd /s /q %Core_Root%
122 xcopy /s %__BinDir% %Core_Root%
125 echo Test Run failed. Refer to the following"
126 echo Msbuild log: %__TestRunBuildLog%
127 echo Html report: %__TestRunHtmlLog%
134 %_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoBuild=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=normal;LogFile="%__TestRunBuildLog%";Append %1 %_buildpostfix% /clp:showcommandline
137 :PerformXunitWrapperBuild
139 %_buildprefix% %_msbuildexe% "%__ProjectFilesDir%runtest.proj" /p:NoRun=true /nologo /maxcpucount /verbosity:minimal /nodeReuse:false /fileloggerparameters:Verbosity=normal;LogFile="%__XunitWrapperBuildLog%";Append %1 %_buildappend%%_buildpostfix%
145 echo %0 BuildArch BuildType [SkipWrapperGeneration] [Exclude EXCLUSION_TARGETS] [TestEnv TEST_ENV_SCRIPT] [vsversion] CORE_ROOT where:
147 echo BuildArch is x64
148 echo BuildType can be: Debug, Release
149 echo SkipWrapperGeneration- Optional parameter - this will run the same set of tests as the last time it was run
150 echo Exclude- Optional parameter - this will exclude individual tests from running, specified by ExcludeList ItemGroup in an .targets file.
151 echo TestEnv- Optional parameter - this will run a custom script to set custom test envirommnent settings.
152 echo VSVersion- optional argument to use VS2013 or VS2015 (default VS2013)
153 echo CORE_ROOT The path to the runtime