Fix TPA map hash calculation. (#288)
[platform/upstream/coreclr.git] / setup_vs_tools.cmd
1 @if not defined _echo @echo off
2
3 REM This script is responsible for setting up either the vs2015 or vs2017 env
4 REM All passed arguments are ignored
5 REM Script will return with 0 if pass, 1 if there is a failure to find either
6 REM vs2015 or vs2017
7
8 :: Default to highest Visual Studio version available
9 ::
10 :: For VS2015 (and prior), only a single instance is allowed to be installed on a box
11 :: and VS140COMNTOOLS is set as a global environment variable by the installer. This
12 :: allows users to locate where the instance of VS2015 is installed.
13 ::
14 :: For VS2017, multiple instances can be installed on the same box SxS and VS150COMNTOOLS
15 :: is no longer set as a global environment variable and is instead only set if the user
16 :: has launched the VS2017 Developer Command Prompt.
17 ::
18 :: Following this logic, we will default to the VS2017 toolset if VS150COMNTOOLS tools is
19 :: set, as this indicates the user is running from the VS2017 Developer Command Prompt and
20 :: is already configured to use that toolset. Otherwise, we will fallback to using the VS2015
21 :: toolset if it is installed. Finally, we will fail the script if no supported VS instance
22 :: can be found.
23
24 if defined VisualStudioVersion (
25     if not defined __VSVersion echo %__MsgPrefix%Detected Visual Studio %VisualStudioVersion% developer command ^prompt environment
26     goto skip_setup
27 )
28
29 echo %__MsgPrefix%Searching ^for Visual Studio 2017 or 2015 installation
30 set _VSWHERE="%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe"
31 if exist %_VSWHERE% (
32     for /f "usebackq tokens=*" %%i in (`%_VSWHERE% -latest -prerelease -property installationPath`) do set _VSCOMNTOOLS=%%i\Common7\Tools
33     goto call_vs
34 )
35 if not exist "%_VSCOMNTOOLS%" set _VSCOMNTOOLS=%VS140COMNTOOLS%
36 echo VS2017 not found, using VS2015
37 :call_vs
38 if not exist "%_VSCOMNTOOLS%" (
39     echo %__MsgPrefix%Error: Visual Studio 2015 or 2017 required.
40     echo        Please see https://github.com/dotnet/coreclr/blob/master/Documentation/building/windows-instructions.md for build instructions.
41     exit /b 1
42 )
43 echo %__MsgPrefix%"%_VSCOMNTOOLS%\VsDevCmd.bat"
44 call "%_VSCOMNTOOLS%\VsDevCmd.bat"
45
46 :skip_setup
47
48 exit /b 0