Godot: Godot cannot find MSBuild.exe with the Visual Studio 2019 Release Candidate

Created on 20 Mar 2019  路  13Comments  路  Source: godotengine/godot

Godot version:

Godot_v3.1-stable_mono_win64 (official distributed binary)

OS/device including version:

Windows 10 x64 Home Edition

Issue description:

When using the new Visual Studio 2019 Release Candidate (16.0.0 RC.3 as of writing) with MSBuild installed, Godot chooses it for building C# solutions. However, MSBuild.exe is not at the same location as with Visual Studio 2017 (and probably previous versions in general).
The usual location was:
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe (modulo a different VS install path)
The new location seems to be:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe

From what I looked up, this is because the last part of the path when trying to find MSBuild.exe is hardcoded:
https://github.com/godotengine/godot/blob/3.1-stable/modules/mono/mono_reg_utils.py#L94

I don't know if there is any "clean way" of knowing the full path to MSBuild.exe for a given VS installation though.

Steps to reproduce:

  • Install the Visual Studio 2019 Release Candidate (downloadable from https://visualstudio.microsoft.com/downloads/)
  • Install the MSBuild component
  • Try to build a project containing any C# script

Godot crashes, leaving a message saying that it couldn't find a file when launching the MSBuild command.

enhancement editor mono

Most helpful comment

I have Jetbrains Rider and it can't find it. Please help!

All 13 comments

Could you please run the following in a Windows command prompt and paste the output here?

"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild

This is the command Godot uses to look up MSBuild.

Here you go:

Visual Studio Locator version 2.6.7+91f4c1d09e [query version 2.0.2250.60958]
Copyright (C) Microsoft Corporation. All rights reserved.

instanceId: 734ce262
installDate: 20/03/2019 13:46:19
installationName: VisualStudio/16.0.0+28714.193.rc.3
installationPath: B:\Program Files (x86)\Microsoft Visual Studio\2019\Community
installationVersion: 16.0.28714.193
productId: Microsoft.VisualStudio.Product.Community
productPath: B:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\devenv.exe
state: 4294967295
isComplete: 1
isLaunchable: 1
isPrerelease: 0
isRebootRequired: 0
displayName: Visual Studio Community聽2019
description: Interface IDE gratuite et riche en fonctionnalit茅s pour les 茅tudiants et les d茅veloppeurs open source et individuels
channelId: VisualStudio.16.Release
channelUri: https://aka.ms/vs/16/release/channel
enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service
releaseNotes: https://go.microsoft.com/fwlink/?LinkId=660893#16.0.0
thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=660909
updateDate: 2019-03-20T12:46:19.7247332Z
catalog_buildBranch: d16.0
catalog_buildVersion: 16.0.28714.193
catalog_id: VisualStudio/16.0.0+28714.193.rc.3
catalog_localBuild: build-lab
catalog_manifestName: VisualStudio
catalog_manifestType: installer
catalog_productDisplayVersion: 16.0.0 RC.3
catalog_productLine: Dev16
catalog_productLineVersion: 2019
catalog_productMilestone: RTW
catalog_productMilestoneIsPreRelease: False
catalog_productName: Visual Studio
catalog_productPatchVersion: 0
catalog_productPreReleaseMilestoneSuffix: 4.3
catalog_productReleaseNameSuffix: RC.3
catalog_productSemanticVersion: 16.0.0+28714.193.rc.3
catalog_requiredEngineVersion: 2.0.3295.64571
properties_campaignId:
properties_channelManifestId: VisualStudio.16.Release/16.0.0+28714.193.rc.3
properties_nickname:
properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\vs_installershell.exe

(My VS 2019 installation is on a B: drive)

Huh, I see that Godot is actually appending a hard coded path to the installation dir for MSBuild, which is not great.

According to the vswhere Wiki, there's a subcommand we could use to directly find msbuild.exe without making assumptions about it's version (Godot appends MSBuild\\15.0\\Bin).
Could you please also run the following and see if it just spits out a full path to msbuild.exe that would be correct for your system?

"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" -latest -products * -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe

It outputs B:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe, which is indeed the full path to VS 2019's MSBuild executable on my machine

Awesome, thanks! (So they replaced it with "Current" heh)

I'll submit a PR to change the detection approach.

edit: I had to check though, the nifty -find parameter is only available in more recent versions of vswhere, sadly.

Is it much of a problem ? vswhere is distributed with the VS installer, which refuses to do anything when it's not up-to-date. Since the installer is required to update the newest Visual Studios, the only reason for a machine to have an older version of vswhere, that doesn't have -find, would be (as far as I know) to have an out-of-date Visual Studio installation (which is quite easily fixable)

Well, Godot doesn't require a user to have VS2019, so anyone who installed VS2017 a while ago would simply not be able to use Godot's msbuild integration if we required support for -find.
However, I just submitted a PR that instead just tests for the Current directory name, which should solve your issue while still supporting VS2017.

VS 2017 uses that same installer, that's why I thought it wouldn't be a big problem. But that could be added later on if the need arises (VS 2021 ?), your PR will probably do the job just as well. Thanks !

Hi Guys Say we have this problem.
Is there a workaround with the current Godot_v3.1-stable_mono_win64 (official distributed binary)
On windows
Or should I install VS 2017 and not the version I have which is 2019

I can't tell if it will work, but you can try creating a softlink
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\15.0
that points to
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current

_The path may be different on your system. You can get it by running C:\ProgramFiles(x86)\Microsoft Visual Studio\Installer\vswhere.exe -latest -products * -requires Microsoft.Component.MSBuild._

Otherwise, your best bet is to wait for a 3.1.1 release which hopefully may happen soon.

Yes I did think that something like that might work but chose instead just to uninstall 19 and install 17
This worked.
But will swap as soon as the 3.1.1 release is out.

@AspenBlack 3.1.1 was just released with support for MSBuild from Visual Studio 2019.

I have Jetbrains Rider and it can't find it. Please help!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

SleepProgger picture SleepProgger  路  3Comments

bojidar-bg picture bojidar-bg  路  3Comments

Zylann picture Zylann  路  3Comments

Spooner picture Spooner  路  3Comments

testman42 picture testman42  路  3Comments