Merge pull request #11297 from DrewScoggins/AddPerfRunInstr
[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 not defined VisualStudioVersion (
20   if defined VS150COMNTOOLS (
21          if not exist "%VS150COMNTOOLS%\..\IDE\devenv.exe"      goto NoVS
22          if not exist "%VS150COMNTOOLS%\..\..\VC\Auxiliary\Build\vcvarsall.bat" goto NoVS
23          if not exist "%VS150COMNTOOLS%\VsDevCmd.bat"                     goto NoVS
24     call "%VS150COMNTOOLS%\VsDevCmd.bat"
25     goto :Run
26   ) else if defined VS140COMNTOOLS (
27          if not exist "%VS140COMNTOOLS%\..\IDE\devenv.exe"      goto NoVS
28          if not exist "%VS140COMNTOOLS%\..\..\VC\vcvarsall.bat" goto NoVS
29          if not exist "%VS140COMNTOOLS%\VsDevCmd.bat"                     goto NoVS
30     call "%VS140COMNTOOLS%\VsDevCmd.bat"
31     goto :Run
32   )
33
34   :NoVS
35   echo Error: Visual Studio 2015 or 2017 required.
36   echo        https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md for build instructions.
37   exit /b 1
38 )
39
40 :Run
41 :: Clear the 'Platform' env variable for this session, as it's a per-project setting within the build, and
42 :: misleading value (such as 'MCD' in HP PCs) may lead to build breakage (issue: #69).
43 set Platform=
44
45 :: Restore the Tools directory
46 call %~dp0init-tools.cmd
47 if NOT [%ERRORLEVEL%]==[0] (
48   exit /b 1
49 )
50
51 :: Always copy over the Tools-Override
52 xcopy %~dp0Tools-Override\* %~dp0Tools /y >nul
53
54 set _toolRuntime=%~dp0Tools
55 set _dotnet=%_toolRuntime%\dotnetcli\dotnet.exe
56 set _json=%~dp0config.json
57
58 :: run.exe depends on running in the root directory, notably because the config.json specifies
59 :: a relative path to the binclash logger
60
61 pushd %~dp0
62 echo Running: %_dotnet% %_toolRuntime%\run.exe %~dp0config.json %*
63 call %_dotnet% %_toolRuntime%\run.exe "%_json%" %*
64 popd
65 if NOT [%ERRORLEVEL%]==[0] (
66   exit /b 1
67 )
68
69 exit /b 0