[bcl] Update BCL Linked Size
[mono-project.git] / msvc / setup-vs-msbuild-env.bat
blobaefeb124966b3881ebd06fc50cdc25d402191952
1 :: Set up VS msbuild environment depending on installed VS versions.\r
2 :: Script will setup environment variables directly in callers environment.\r
3 \r
4 :: Make sure we can restore current working directory after setting up environment.\r
5 :: Some of the VS scripts can change the current working directory.\r
6 set CALLER_WD=%CD%\r
7 \r
8 :: Get path for current running script.\r
9 set RUN_SETUP_VS_MSBUILD_ENV_SCRIPT_PATH=%~dp0\r
11 :: Visual Studio 2015 == 14.0\r
12 if "%VisualStudioVersion%" == "14.0" (\r
13     goto SETUP_VS_2015\r
14 )\r
16 :: Visual Studio 2017 == 15.0\r
17 if "%VisualStudioVersion%" == "15.0" (\r
18     goto SETUP_VS_2017\r
19 )\r
21 :SETUP_VS_2015\r
23 :SETUP_VS_2015_BUILD_TOOLS\r
25 :: Try to locate VS2015 build tools installation.\r
26 set VS_2015_BUILD_TOOLS_CMD=%ProgramFiles(x86)%\Microsoft Visual C++ Build Tools\vcbuildtools_msbuild.bat\r
28 :: Setup VS2015 VC development environment using build tools installation.\r
29 call :setup_build_env "%VS_2015_BUILD_TOOLS_CMD%" "%CALLER_WD%" && (\r
30     goto ON_EXIT\r
31 )\r
33 :SETUP_VS_2015_VC\r
35 :: Try to locate installed VS2015 VC environment.\r
36 set VS_2015_DEV_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Tools\VsMSBuildCmd.bat\r
38 :: Setup VS2015 VC development environment using VS installation.\r
39 call :setup_build_env "%VS_2015_DEV_CMD%" "%CALLER_WD%" && (\r
40     goto ON_EXIT\r
41 )\r
43 :SETUP_VS_2017\r
45 :SETUP_VS_2017_BUILD_TOOLS\r
47 :: Try to locate VS2017 build tools installation.\r
48 set VS_2017_BUILD_TOOLS_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat\r
50 :: Setup VS2017 VC development environment using build tools installation.\r
51 call :setup_build_env "%VS_2017_BUILD_TOOLS_CMD%" "%CALLER_WD%" && (\r
52     goto ON_EXIT\r
53 )\r
55 :SETUP_VS_2017_VC\r
57 :: VS2017 includes vswhere.exe that can be used to locate current VS2017 installation.\r
58 set VSWHERE_TOOLS_BIN=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe\r
59 set VS_2017_DEV_CMD=\r
61 :: Try to locate installed VS2017 VC environment.\r
62 if exist "%VSWHERE_TOOLS_BIN%" (\r
63     for /f "tokens=*" %%a in ('"%VSWHERE_TOOLS_BIN%" -latest -property installationPath') do (\r
64         set VS_2017_DEV_CMD=%%a\Common7\Tools\VsMSBuildCmd.bat\r
65     )\r
66 )\r
68 :: Setup VS2017 VC development environment using VS installation.\r
69 call :setup_build_env "%VS_2017_DEV_CMD%" "%CALLER_WD%" && (\r
70     goto ON_EXIT\r
71 )\r
73 :ON_ENV_ERROR\r
75 echo Warning, failed to setup VS build environment needed by VS tooling.\r
76 echo Incomplete build environment can cause build error's due to missing compiler,\r
77 echo linker and platform libraries.\r
79 exit /b 1\r
81 :ON_EXIT\r
83 exit /b 0\r
85 :setup_build_env\r
87 :: Check if VS build environment script exists.\r
88 if not exist "%~1" (\r
89     goto setup_build_env_error\r
90 )\r
92 :: Run VS build environment script.\r
93 call "%~1" > NUL\r
95 :: Restore callers working directory in case it has been changed by VS scripts.\r
96 cd /d "%~2"\r
98 goto setup_build_env_exit\r
100 :setup_build_env_error\r
101 exit /b 1\r
103 :setup_build_env_exit\r
104 goto :EOF