Merge pull request #14334 from BruceForstall/AddTestEnvToWindows
[platform/upstream/coreclr.git] / run.cmd
1 @if not defined _echo @echo off
2 setlocal
3
4 :: Default to highest Visual Studio version available
5 ::
6 :: For VS2015 (and prior), only a single instance is allowed to be installed on a box
7 :: and VS140COMNTOOLS is set as a global environment variable by the installer. This
8 :: allows users to locate where the instance of VS2015 is installed.
9 ::
10 :: For VS2017, multiple instances can be installed on the same box SxS and VS150COMNTOOLS
11 :: is no longer set as a global environment variable and is instead only set if the user
12 :: has launched the VS2017 Developer Command Prompt.
13 ::
14 :: Following this logic, we will default to the VS2017 toolset if VS150COMNTOOLS tools is
15 :: set, as this indicates the user is running from the VS2017 Developer Command Prompt and
16 :: is already configured to use that toolset. Otherwise, we will fallback to using the VS2015
17 :: toolset if it is installed. Finally, we will fail the script if no supported VS instance
18 :: can be found.
19 if defined VisualStudioVersion goto :Run
20
21 set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
22 if exist %_VSWHERE% (
23   for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools
24 )
25 if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
26 if not exist "%_VSCOMNTOOLS%" (
27   echo Error: Visual Studio 2015 or 2017 required.
28   echo        Please see https://github.com/dotnet/corefx/blob/master/Documentation/project-docs/developer-guide.md for build instructions.
29   exit /b 1
30 )
31
32 call "%_VSCOMNTOOLS%\VsDevCmd.bat"
33
34 :Run
35 :: Clear the 'Platform' env variable for this session, as it's a per-project setting within the build, and
36 :: misleading value (such as 'MCD' in HP PCs) may lead to build breakage (issue: #69).
37 set Platform=
38
39 :: Restore the Tools directory
40 call %~dp0init-tools.cmd
41 if NOT [%ERRORLEVEL%]==[0] (
42   exit /b 1
43 )
44
45 set _toolRuntime=%~dp0Tools
46 set _dotnet=%_toolRuntime%\dotnetcli\dotnet.exe
47 set _json=%~dp0config.json
48
49 :: run.exe depends on running in the root directory, notably because the config.json specifies
50 :: a relative path to the binclash logger
51
52 pushd %~dp0
53 echo Running: %_dotnet% %_toolRuntime%\run.exe %~dp0config.json %*
54 call %_dotnet% %_toolRuntime%\run.exe "%_json%" %*
55 popd
56 if NOT [%ERRORLEVEL%]==[0] (
57   exit /b 1
58 )
59
60 exit /b 0