MSBuild.exe not found, cmd.exe

19,930

You can use vswhere 1 which comes with Visual Studio 2017. It is located in "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe".

The part of the path to MSBuild.exe is then retrived by vswhere -nologo -latest -property installationPath, which results e.g., in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community. Based on the msbuild Version you want to use you can now guess the rest of the path:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\VERSION\Bin\MSBuild.exe

where VERSION is e.g., 15.0 for Version installationVersion: 15.3.26730.12as ouputed by "%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -property installationVersion.

1 See GitHub

Share:
19,930
Valerii Gruu
Author by

Valerii Gruu

Updated on June 15, 2022

Comments

  • Valerii Gruu
    Valerii Gruu almost 2 years

    I recently installed Visual Studio 2017, shouldn't MSBuild.exe come with it? One of bash scripts is calling it, but can't find anything.

    Here is the part of build.bat that yields error (you can see the whole file here)

    MSBuild.exe mpc-hc.sln %MSBUILD_SWITCHES%^
     /target:%BUILDTYPE% /property:Configuration="%BUILDCFG% Filter";Platform=%1^
     /flp1:LogFile=%LOG_DIR%\filters_errors_%BUILDCFG%_%1.log;errorsonly;Verbosity=diagnostic^
     /flp2:LogFile=%LOG_DIR%\filters_warnings_%BUILDCFG%_%1.log;warningsonly;Verbosity=diagnostic
    IF %ERRORLEVEL% NEQ 0 (
      CALL "%COMMON%" :SubMsg "ERROR" "mpc-hc.sln %BUILDCFG% Filter %1 - Compilation failed!"
      EXIT /B
    ) ELSE (
      CALL "%COMMON%" :SubMsg "INFO" "mpc-hc.sln %BUILDCFG% Filter %1 compiled successfully"
    )