Open KirillOsenkov opened 7 years ago
Here's a simple tool I wrote to debug this: https://github.com/KirillOsenkov/VSInstanceFinder
And here's the official vswhere repo: https://github.com/Microsoft/VSWhere
I've been hit by the same issue.
@KirillOsenkov Did you find a way to fix the install on the computer?
Yes, I've launched the Visual Studio Installer and uninstalled or updated to make sure that all installed VS instances are healthy.
Ok thx!
I guess having a detailed log would allow understanding what's going on. I've spent a lot of time figuring out what's happening as it was on someone else's computer 😭
The code the code is not trivial at all, there's a lot of differnt code paths for MsBuildPath detection (BuildEnvironmentHelper
) but also for toolsets detection (ToolsetReader
).
On one machine my VS 2017 installation had errors (which is apparently not uncommon). On that machine hosting MSBuild 15 resulted in a lot of hard-to-diagnose problems. After some investigation I've narrowed it down to the codepath enumerating VS 2017 installations not returning any instances.
It turns out the code here is not tolerant against this case: http://source.dot.net/#Microsoft.Build/SharedUtilities/VisualStudioLocationHelper.cs,59
It checks for InstanceState.Complete, which is sometimes too restrictive. Here's the InstanceState enum:
The code in MSBuild only adds an instance if the state is Complete. However on the machine in question the state was Local | Registered | NoRebootRequired. Due to errors during setup the NoErrors flags was not set.
My understanding is that this check should include the instance if the state is anything but None or maybe ignore the State flag entirely.