add_msbuild_path.cmd 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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 USE_MSBUILD_12=%1
  9. if "%USE_MSBUILD_12%" == "True" (
  10. echo Skipping Dev14 and trying Dev12...
  11. goto :LABEL_USE_MSBUILD_12
  12. )
  13. where /q msbuild.exe
  14. if "%ERRORLEVEL%" == "0" (
  15. goto :SkipMsBuildSetup
  16. )
  17. REM Try Dev14 first
  18. set MSBUILD_VERSION=14.0
  19. set MSBUILD_PATH="%ProgramFiles%\msbuild\%MSBUILD_VERSION%\Bin\x86"
  20. if not exist %MSBUILD_PATH%\msbuild.exe (
  21. set MSBUILD_PATH="%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin"
  22. )
  23. if not exist %MSBUILD_PATH%\msbuild.exe (
  24. set MSBUILD_PATH="%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin\amd64"
  25. )
  26. if exist %MSBUILD_PATH%\msbuild.exe (
  27. goto :MSBuildFound
  28. )
  29. echo Dev14 not found, trying Dev12...
  30. :LABEL_USE_MSBUILD_12
  31. set MSBUILD_VERSION=12.0
  32. set MSBUILD_PATH="%ProgramFiles%\msbuild\%MSBUILD_VERSION%\Bin\x86"
  33. echo Dev14 not found, trying Dev %MSBUILD_VERSION%
  34. if not exist %MSBUILD_PATH%\msbuild.exe (
  35. set MSBUILD_PATH="%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin"
  36. )
  37. if not exist %MSBUILD_PATH%\msbuild.exe (
  38. set MSBUILD_PATH="%ProgramFiles(x86)%\msbuild\%MSBUILD_VERSION%\Bin\amd64"
  39. )
  40. if not exist %MSBUILD_PATH%\msbuild.exe (
  41. echo Can't find msbuild.exe in %MSBUILD_PATH%
  42. goto :SkipMsBuildSetup
  43. )
  44. :MSBuildFound
  45. echo MSBuild located at %MSBUILD_PATH%
  46. set PATH=%MSBUILD_PATH%;%PATH%
  47. set USE_MSBUILD_12=
  48. set MSBUILD_PATH=
  49. :SkipMsBuildSetup