detect_msvc_vswhere.cmd 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. if NOT "%verbose%" == "" (
  2. echo Detecting msvc %BUILD_VS_YEAR%
  3. )
  4. set ProgramFilesX86=%ProgramFiles(x86)%
  5. if not exist "%ProgramFilesX86%" set ProgramFilesX86=%ProgramFiles%
  6. set vs_where=%ProgramFilesX86%\Microsoft Visual Studio\Installer\vswhere.exe
  7. if not exist "%vs_where%" (
  8. if NOT "%verbose%" == "" (
  9. echo Visual Studio %BUILD_VS_YEAR% is not detected
  10. )
  11. goto FAIL
  12. )
  13. if NOT "%verbose%" == "" (
  14. echo "%vs_where%" -latest %VSWHERE_ARGS% -version ^[%BUILD_VS_VER%.0^,%BUILD_VS_VER%.99^) -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64
  15. )
  16. for /f "usebackq tokens=1* delims=: " %%i in (`"%vs_where%" -latest -version ^[%BUILD_VS_VER%.0^,%BUILD_VS_VER%.99^) %VSWHERE_ARGS% -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64`) do (
  17. if /i "%%i"=="installationPath" set VS_InstallDir=%%j
  18. )
  19. if NOT "%verbose%" == "" (
  20. echo VS_Installdir="%VS_InstallDir%"
  21. )
  22. if "%VS_InstallDir%"=="" (
  23. if NOT "%verbose%" == "" (
  24. echo Visual Studio is detected but the "Desktop development with C++" workload has not been instlled
  25. goto FAIL
  26. )
  27. )
  28. set VCVARS=%VS_InstallDir%\VC\Auxiliary\Build\vcvarsall.bat
  29. if exist "%VCVARS%" (
  30. call "%VCVARS%" %BUILD_ARCH%
  31. ) else (
  32. if NOT "%verbose%" == "" (
  33. echo "%VCVARS%" not found
  34. )
  35. goto FAIL
  36. )
  37. rem try msbuild
  38. msbuild /version > NUL
  39. if errorlevel 1 (
  40. if NOT "%verbose%" == "" (
  41. echo Visual Studio %BUILD_VS_YEAR% msbuild not found
  42. )
  43. goto FAIL
  44. )
  45. if NOT "%verbose%" == "" (
  46. echo Visual Studio %BUILD_VS_YEAR% msbuild found
  47. )
  48. REM try the c++ compiler
  49. cl 2> NUL 1>&2
  50. if errorlevel 1 (
  51. if NOT "%verbose%" == "" (
  52. echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler not found
  53. )
  54. goto FAIL
  55. )
  56. if NOT "%verbose%" == "" (
  57. echo Visual Studio %BUILD_VS_YEAR% C/C++ Compiler found
  58. )
  59. if NOT "%verbose%" == "" (
  60. echo Visual Studio %BUILD_VS_YEAR% is detected successfully
  61. )
  62. goto EOF
  63. :FAIL
  64. exit /b 1
  65. :EOF