7

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"
)
Valerii Gruu
  • 155
  • 1
  • 2
  • 6
  • Have you searched for the file? – Stefan Sep 14 '17 at 16:13
  • Your bash script isn't calling it. Proof: examining your question I see no bash script calling it. –  Sep 14 '17 at 16:15
  • @Stefan There is one in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\amd64 and one in C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin , what's the difference between them? – Valerii Gruu Sep 14 '17 at 16:18
  • [edit] in the relevant parts of the script –  Sep 14 '17 at 16:20
  • Has it changed [since the beta version](https://stackoverflow.com/questions/40694598/how-do-i-call-visual-studio-2017-rcs-version-of-msbuild-from-a-bat-file)? – Cody Gray - on strike Sep 14 '17 at 16:22
  • @Will edited, here – Valerii Gruu Sep 14 '17 at 16:31
  • It is hard to find back in VS2017. You must use the "Developer Command Prompt for VS2017" to ensure the PATH is set correctly. You did not mention using it so probably what you forgot to do. – Hans Passant Sep 14 '17 at 16:38
  • 2
    @HansPassant launching "Developer Command Prompt for VS 2017" with "where msbuild" showed one in `Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin` and one in `C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe` . I guess I'll use first one, and hope for the best. – Valerii Gruu Sep 14 '17 at 16:46
  • Not having to guess is the point of using it. Just run you .bat file as-is. – Hans Passant Sep 14 '17 at 17:00

1 Answers1

12

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

user69453
  • 1,279
  • 1
  • 17
  • 43