6 :: Make sure we can restore current working directory after setting up environment.
7 :: Some of the VS scripts can change the current working directory.
10 :: Visual Studio 2015 == 14.0
11 if "%VisualStudioVersion%" == "14.0" (
15 :: Visual Studio 2017 == 15.0
16 if "%VisualStudioVersion%" == "15.0" (
22 :SETUP_VS_2015_BUILD_TOOLS
24 :: Try to locate VS2015 build tools installation.
25 set VS_2015_BUILD_TOOLS_CMD=%ProgramFiles(x86)%\Microsoft Visual C++ Build Tools\vcbuildtools_msbuild.bat
27 :: Setup VS2015 VC development environment using build tools installation.
28 call :setup_build_env "%VS_2015_BUILD_TOOLS_CMD%" "%CALLER_WD%" && (
34 :: Try to locate installed VS2015 VC environment.
35 set VS_2015_DEV_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio 14.0\Common7\Tools\VsMSBuildCmd.bat
37 :: Setup VS2015 VC development environment using VS installation.
38 call :setup_build_env "%VS_2015_DEV_CMD%" "%CALLER_WD%" && (
44 :SETUP_VS_2017_BUILD_TOOLS
46 :: Try to locate VS2017 build tools installation.
47 set VS_2017_BUILD_TOOLS_CMD=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\BuildTools\Common7\Tools\VsMSBuildCmd.bat
49 :: Setup VS2017 VC development environment using build tools installation.
50 call :setup_build_env "%VS_2017_BUILD_TOOLS_CMD%" "%CALLER_WD%" && (
56 :: VS2017 includes vswhere.exe that can be used to locate current VS2017 installation.
57 set VSWHERE_TOOLS_BIN=%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe
60 :: Try to locate installed VS2017 VC environment.
61 if exist "%VSWHERE_TOOLS_BIN%" (
62 for /f "tokens=*" %%a in ('"%VSWHERE_TOOLS_BIN%" -latest -property installationPath') do (
63 set VS_2017_DEV_CMD=%%a\Common7\Tools\VsMSBuildCmd.bat
67 :: Setup VS2017 VC development environment using VS installation.
68 call :setup_build_env "%VS_2017_DEV_CMD%" "%CALLER_WD%" && (
74 echo Warning, failed to setup build environment needed by msbuild.exe.
75 echo Incomplete build environment can cause build error's due to missing compiler, linker and platform libraries.
79 call "msbuild.exe" /t:RunWinConfigSetup mono.winconfig.targets && (
83 if not %ERRORLEVEL% == 0 (
84 set BUILD_RESULT=%ERRORLEVEL%
88 exit /b %BUILD_RESULT%
92 :: Check if VS build environment script exists.
94 goto setup_build_env_error
97 :: Run VS build environment script.
100 :: Restore callers working directory in case it has been changed by VS scripts.
103 goto setup_build_env_exit
105 :setup_build_env_error
108 :setup_build_env_exit