add_msbuild_path.cmd 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. ::-------------------------------------------------------------------------------------------------------
  2. :: Copyright (C) Microsoft. All rights reserved.
  3. :: Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. ::-------------------------------------------------------------------------------------------------------
  5. :: add_msbuild_path.cmd
  6. ::
  7. :: Locate msbuild.exe and add it to the PATH
  8. set FORCE_MSBUILD_VERSION=%1
  9. if "%FORCE_MSBUILD_VERSION%" == "msbuild14" (
  10. echo Skipping Dev15 and trying Dev14...
  11. goto :LABEL_USE_MSBUILD_14
  12. )
  13. where /q msbuild.exe
  14. if "%ERRORLEVEL%" == "0" (
  15. goto :SkipMsBuildSetup
  16. )
  17. REM Try Dev15 first
  18. echo Trying to locate Dev15...
  19. :LABEL_USE_MSBUILD_15
  20. set MSBUILD_VERSION=15.0
  21. set "MSBUILD_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\Preview\Enterprise\MSBuild\15.0\Bin"
  22. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  23. set "MSBUILD_PATH=%ProgramFiles%\Microsoft Visual Studio\2017\Enterprise\MSBuild\%MSBUILD_VERSION%\Bin\x86"
  24. )
  25. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  26. set "MSBUILD_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\%MSBUILD_VERSION%\Bin"
  27. )
  28. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  29. set "MSBUILD_PATH=%ProgramFiles(x86)%\Microsoft Visual Studio\2017\Enterprise\MSBuild\%MSBUILD_VERSION%\Bin\amd64"
  30. )
  31. if exist "%MSBUILD_PATH%\msbuild.exe" (
  32. goto :MSBuildFound
  33. )
  34. echo Dev15 not found, trying to locate Dev14...
  35. :LABEL_USE_MSBUILD_14
  36. set MSBUILD_VERSION=14.0
  37. set "MSBUILD_PATH=%ProgramFiles%\msbuild\%MSBUILD_VERSION%\Bin\x86"
  38. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  39. set "MSBUILD_PATH=%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin"
  40. )
  41. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  42. set "MSBUILD_PATH=%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin\amd64"
  43. )
  44. if exist "%MSBUILD_PATH%\msbuild.exe" (
  45. goto :MSBuildFound
  46. )
  47. echo Dev14 not found, trying to locate Dev12...
  48. :LABEL_USE_MSBUILD_12
  49. set MSBUILD_VERSION=12.0
  50. set "MSBUILD_PATH=%ProgramFiles%\msbuild\%MSBUILD_VERSION%\Bin\x86"
  51. echo Dev14 not found, trying Dev %MSBUILD_VERSION%
  52. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  53. set "MSBUILD_PATH=%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin"
  54. )
  55. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  56. set "MSBUILD_PATH=%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin\amd64"
  57. )
  58. if not exist "%MSBUILD_PATH%\msbuild.exe" (
  59. echo Can't find msbuild.exe in "%MSBUILD_PATH%"
  60. goto :SkipMsBuildSetup
  61. )
  62. :MSBuildFound
  63. echo MSBuild located at "%MSBUILD_PATH%"
  64. set "PATH=%MSBUILD_PATH%;%PATH%"
  65. set USE_MSBUILD_12=
  66. set MSBUILD_PATH=
  67. :SkipMsBuildSetup