MSBuild.exe not found, cmd.exe

三世轮回 提交于 2019-12-12 10:24:41

问题


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"
)

回答1:


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



来源:https://stackoverflow.com/questions/46223916/msbuild-exe-not-found-cmd-exe

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!