'"Could not locate MSBuild instance to register with OmniSharp" but msbuild is installed
Due to the third party system we work against, I have to use .Net 2.1, which has worked fine until recently. I develop on Fedora with latest updates and VSCode. This seems similar to Could not locate MSBuild instance to register with OmniSharp but I get the warning about msbuild version number, where that question did not.
Now when opening my VSCode project I get this Omnisharp output:
Starting OmniSharp server at 28/03/2022, 09:48:44
Target: /home/neek/workspace/LinnworksNetSDKProjects/PremierZenCartMacro/Linnworks/Examples/OrdersDashboard/dotnet/LinnworksNet-NativeModule-OrdersDashboard.sln
OmniSharp server started with Mono 6.12.0.
Path: /home/neek/.vscode/extensions/ms-dotnettools.csharp-1.24.1/.omnisharp/1.38.3-beta.31/omnisharp/OmniSharp.exe
PID: 8252
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Cake, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.DotNetTest, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Host, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.MSBuild, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Roslyn.CSharp, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Script, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[dbug]: OmniSharp.CompositionHostBuilder
Loaded OmniSharp.Shared, Version=1.38.0.0, Culture=neutral, PublicKeyToken=7e5bf7b3b470b509
[info]: OmniSharp.Stdio.Host
Starting OmniSharp on fedora 35.0 (x64)
[info]: OmniSharp.Services.DotNetCliService
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
[info]: OmniSharp.Services.DotNetCliService
DotNetPath set to /home/neek/dotnet/dotnet
[dbug]: OmniSharp.CompositionHostBuilder
.NET SDK requires MSBuild instances version 16.0.0 or higher
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
Located 0 MSBuild instance(s)
Could not locate MSBuild instance to register with OmniSharp.
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).
It claims .NET SDK requires MSBuild instances version 16.0.0 or higher
however I believe this is installed:
$ dotnet msbuild -h
Microsoft (R) Build Engine version 16.2.37902+b5aaefc9f for .NET Core
Copyright (C) Microsoft Corporation. All rights reserved.
dotnet was installed manually under my home directory and added to the $PATH
as per installation instructions:
$ which dotnet
~/dotnet/dotnet
Could be related to https://github.com/OmniSharp/omnisharp-vscode/issues/5120 where they talk about omnisharp.useModernNet
. In my Settings UI in VSCode, I can see 'Use Modern Net' is false, which I think is correct as I don't want to use a 'modern' .Net, I have to use the 2.1 SDK.
If I set useModernNet to true, then omnisharp appears to download .Net 6 packages:
Installing C# dependencies...
Platform: linux, x86_64, name=fedora, version=35
Downloading package 'OmniSharp for Linux (.NET 6 / x64)' (39471 KB).................... Done!
Validating download...
Integrity Check succeeded.
Installing package 'OmniSharp for Linux (.NET 6 / x64)'
Finished
Getting latest OmniSharp version information
Downloading package 'Latest OmniSharp Version Information' (1 KB).................... Done!
I can then run the 'build' command (my tasks.json
specifies the command
as /home/neek/dotnet/dotnet
) and it appears to compile normally.
It is wrong to be telling Omnisharp to use .Net 6 when my code actually wants to compile using the 2.1 SDK installed? Should I be turning off useModernNet
, and if so, how to I fix the Omnisharp error about not finding msbuild?
Solution 1:[1]
Remove the msbuild error by setting the following:
"omnisharp.path": ""
Use the newer .NET 6.0 version of OmniSharp (which has nothing to do with your code and target framework) by setting the following:
"omnisharp.useModernNet": true
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 | Mani Gandham |