[llvm] Disable running the llvm verifier by default, it was enabled by mistake, and...
[mono-project.git] / msvc / setup-vs-msbuild-env.bat
blob1d5852e1cdd94e9d226235643eb9fe1e20455a4a
1 :: Set up VS msbuild environment depending on installed VS versions.
2 :: Script will setup environment variables directly in callers environment.
4 :: Make sure we can restore current working directory after setting up environment.
5 :: Some of the VS scripts can change the current working directory.
6 set CALLER_WD=%CD%
8 :: Get path for current running script.
9 set RUN_SETUP_VS_MSBUILD_ENV_SCRIPT_PATH=%~dp0
11 :: VS2017/VS2019 includes vswhere.exe that can be used to locate current VS installation.
12 set VSWHERE_TOOLS_BIN=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
14 :: Visual Studio 2015 == 14.0
15 if "%VisualStudioVersion%" == "14.0" (
16     goto SETUP_VS_2015
19 :: Visual Studio 2017 == 15.0
20 if "%VisualStudioVersion%" == "15.0" (
21     goto SETUP_VS_2017
24 :: Visual Studio 2019 == 16.0
25 if "%VisualStudioVersion%" == "16.0" (
26     goto SETUP_VS_2019
29 :SETUP_VS_2019
31 :SETUP_VS_2019_BUILD_TOOLS
33 :: Try to locate VS2019 build tools installation.
34 set VS_2019_BUILD_TOOLS_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\2019\BuildTools\Common7\Tools\VsMSBuildCmd.bat
36 :: Setup VS2019 VC development environment using build tools installation.
37 call :setup_build_env "%VS_2019_BUILD_TOOLS_CMD%" "%CALLER_WD%" && (
38     set VS_DEFAULT_PLATFORM_TOOL_SET=v142
39     goto ON_EXIT
42 :SETUP_VS_2019_VC
44 set VS_2019_DEV_CMD=
46 :: Try to locate installed VS2019 VC environment.
47 if exist "%VSWHERE_TOOLS_BIN%" (
48     for /f "tokens=*" %%a in ('"%VSWHERE_TOOLS_BIN%" -version [16.0^,17.0] -prerelease -property installationPath') do (
49         set VS_2019_DEV_CMD=%%a\Common7\Tools\VsMSBuildCmd.bat
50     )
53 :: Setup VS2019 VC development environment using VS installation.
54 call :setup_build_env "%VS_2019_DEV_CMD%" "%CALLER_WD%" && (
55     set VS_DEFAULT_PLATFORM_TOOL_SET=v142
56     goto ON_EXIT
59 :SETUP_VS_2017
61 :SETUP_VS_2017_BUILD_TOOLS
63 :: Try to locate VS2017 build tools installation.
64 set VS_2017_BUILD_TOOLS_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat
66 :: Setup VS2017 VC development environment using build tools installation.
67 call :setup_build_env "%VS_2017_BUILD_TOOLS_CMD%" "%CALLER_WD%" && (
68     set VS_DEFAULT_PLATFORM_TOOL_SET=v141
69     goto ON_EXIT
72 :SETUP_VS_2017_VC
74 set VS_2017_DEV_CMD=
76 :: Try to locate installed VS2017 VC environment.
77 if exist "%VSWHERE_TOOLS_BIN%" (
78     for /f "tokens=*" %%a in ('"%VSWHERE_TOOLS_BIN%" -version [15.0^,16.0] -property installationPath') do (
79         set VS_2017_DEV_CMD=%%a\Common7\Tools\VsMSBuildCmd.bat
80     )
83 :: Setup VS2017 VC development environment using VS installation.
84 call :setup_build_env "%VS_2017_DEV_CMD%" "%CALLER_WD%" && (
85     set VS_DEFAULT_PLATFORM_TOOL_SET=v141
86     goto ON_EXIT
89 :SETUP_VS_2015
91 :SETUP_VS_2015_BUILD_TOOLS
93 :: Try to locate VS2015 build tools installation.
94 set VS_2015_BUILD_TOOLS_CMD=%ProgramFiles(x86)%\Microsoft Visual C++ Build Tools\vcbuildtools_msbuild.bat
96 :: Setup VS2015 VC development environment using build tools installation.
97 call :setup_build_env "%VS_2015_BUILD_TOOLS_CMD%" "%CALLER_WD%" && (
98     set VS_DEFAULT_PLATFORM_TOOL_SET=v140
99     goto ON_EXIT
102 :SETUP_VS_2015_VC
104 :: Try to locate installed VS2015 VC environment.
105 set VS_2015_DEV_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Tools\VsMSBuildCmd.bat
107 :: Setup VS2015 VC development environment using VS installation.
108 call :setup_build_env "%VS_2015_DEV_CMD%" "%CALLER_WD%" && (
109     set VS_DEFAULT_PLATFORM_TOOL_SET=v140
110     goto ON_EXIT
113 :ON_ENV_ERROR
115 echo Warning, failed to setup VS build environment needed by VS tooling.
116 echo Incomplete build environment can cause build error's due to missing compiler,
117 echo linker and platform libraries.
119 exit /b 1
121 :ON_EXIT
123 exit /b 0
125 :setup_build_env
127 :: Check if VS build environment script exists.
128 if not exist "%~1" (
129     goto setup_build_env_error
132 :: Run VS build environment script.
133 call "%~1" > NUL
135 :: Restore callers working directory in case it has been changed by VS scripts.
136 cd /d "%~2"
138 goto setup_build_env_exit
140 :setup_build_env_error
141 exit /b 1
143 :setup_build_env_exit
144 goto :EOF