'Could not locate MSBuild instance to register with OmniSharp
I have found many questions about this but non have helped me. I am trying to write c# code and the omnisharp auto complete doesn't work and I get this back from the Omnisharp Log:
OmniSharp server started.
Path: c:\Users\GeorgV.216\.vscode\extensions\ms-dotnettools.csharp-1.24.1\.omnisharp\1.38.3-beta.31\OmniSharp.exe
PID: 11536
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on Windows 6.2.9200.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
Using the 'dotnet' on the PATH.
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 0 MSBuild instance(s)
Could not locate MSBuild instance to register with OmniSharp.
What could be a possible solution?
Solution 1:[1]
The solution that worked for me was to change the "omnisharp.path": from "latest" to "" in the setting.json file and delete the 1.38.3-beta.31 folder in C:\Users{username}.vscode\extensions\ms-dotnettools.csharp-1.24.1.omnisharp
Solution 2:[2]
Suddenly got this problem too, adding "omnisharp.useModernNet": true to the settings.json fixed it for me.
Solution 3:[3]
Omnisharp has been updated to .NET 6.0. The older .NET Framework builds will no longer ship with MSBuild tools (and you don't already have them installed) so that's the reason for your error.
Remove the msbuild error by setting the following in VSCode settings.json:
"omnisharp.path": ""
Upgrade to the newer .NET 6.0 builds of OmniSharp by setting the following:
"omnisharp.useModernNet": true
Solution 4:[4]
Working for me now. Maybe the cause is (from omnisharp github): "Planned removal of the included Mono & MSBuild Tools
In the future .NET Framework builds of OmniSharp will not ship with Mono or the MSBuild tooling (See announcement omnisharp-roslyn#2339). To ensure that the C# extension remains usable out of the box for .NET SDK projects, we will be changing the default value of omnisharp.useModernNet to true."
But " omnisharp.useModernNet to true" does not work with Unity 3d.
So.
I uninstall all dotnets from ubuntu. Unistall mono. Reinstall dotnet using this: https://docs.microsoft.com/es-es/dotnet/core/install/linux-ubuntu#2110- Reinstall mono-complete using synaptics. And in VS settings set omnisharp using global mono to "always". Now it's working for me.
Solution 5:[5]
The solution that worked for me:
Manage Settings search for
"omnisharp path"
edit insettings.json
enter code here> replace "latest" with ""
Solution 6:[6]
For me runs with
"omnisharp.enableEditorConfigSupport": true,
"omnisharp.path": "latest",
"omnisharp.projectLoadTimeout": 60,
"omnisharp.useGlobalMono": "always",
"omnisharp.useModernNet": true,
on settings.json file....
Solution 7:[7]
As of May 2022, Omnisharp does not include MSBuild. Download link can be found at the bottom of this page. In the install select the following option:
More info in this issue.
Solution 8:[8]
Here is text from release note for Omnisharp v1.25.0: "Announcement: The C# extension no longer ships with an included Mono & MSBuild Tools". I have installed .Net 6.0 and omnisharp v1.25.0 was able to locate MSBuild from there.
The older version of Omnisharp has MSBuild available within their extension install folder C:\Users\Username.vscode\extensions\ms-dotnettools.csharp-XX.XX.XX....omnisharp\X.XX.XX\msbuild
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Shawn Sean |
Solution 2 | Koi Tri |
Solution 3 | |
Solution 4 | Kunta Kinte |
Solution 5 | Paul Povel |
Solution 6 | Messias Soares |
Solution 7 | chantey |
Solution 8 | CSharp |