Was asked to create new issue on https://github.com/OmniSharp/omnisharp-vscode/issues/2876
dotnet --info output:
PS C:sourcepocomnisharp-issue> dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.2.203
Commit: e5bab63eca
Runtime Environment:
OS Name: Windows
OS Version: 10.0.14393
OS Platform: Windows
RID: win10-x64
Base Path: C:Program Filesdotnetsdk2.2.203
Host (useful for support):
Version: 2.2.4
Commit: f95848e524
.NET Core SDKs installed:
1.0.0 [C:Program Filesdotnetsdk]
1.0.1 [C:Program Filesdotnetsdk]
1.0.4 [C:Program Filesdotnetsdk]
2.0.0 [C:Program Filesdotnetsdk]
2.0.2 [C:Program Filesdotnetsdk]
2.1.4 [C:Program Filesdotnetsdk]
2.1.300 [C:Program Filesdotnetsdk]
2.1.302 [C:Program Filesdotnetsdk]
2.2.104 [C:Program Filesdotnetsdk]
2.2.203 [C:Program Filesdotnetsdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.2 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.4 [C:Program FilesdotnetsharedMicrosoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.4 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 1.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 1.1.1 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
Microsoft.NETCore.App 2.2.4 [C:Program FilesdotnetsharedMicrosoft.NETCore.App]
To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download
1.33.1
ms-vscode.csharp-1.19.0.omnisharp1.32.18
Created a new .NET Core project based on 2.2.203
Repo that gives me issue - https://github.com/tonyranieri/omnisharp-poc
I don't get the exception and the project loads.
Exception when loading, no OmniSharp functionality.
If I pin the version to 2.2.104 via the global.json and reload VS Code it works as expected.
Locatted 2 MSBuild instance(s)
1: Visual Studio Enterprise 2017 15.4.27004.2008 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
2: StandAlone 15.0 - "C:\Users\ranieria\.vscode\extensions\ms-vscode.csharp-1.19.0\.omnisharp\1.32.18\.msbuild\Current\Bin"
I believe it is preferring (1) over (2). @rchande is there a way to control which msbuild instance is selected? If not, you'd need to uninstall VS 2017 or install VS 2019, I guess.
Also, it's confusing that (2) is described as StandAlone 15.0 instead of StandAlone 16.0.
is there a way to control which msbuild instance is selected?
at the moment it's unfortunately hardcoded https://github.com/OmniSharp/omnisharp-roslyn/blob/6836fadb9c35a88d4695276d14302336a460b841/src/OmniSharp.Host/MSBuild/Discovery/MSBuildLocator.cs#L44-L50
Also, it's confusing that (2) is described as StandAlone 15.0 instead of StandAlone 16.0.
that is also currently hardcoded
I think @akshita31 filed a bug for us to track enabling a choice?
Solved this problem by adding omnisharp.json with
{
"MsBuild": {
"UseLegacySdkResolver": true
}
}
@themindfulcoder Do you mean that file should be added to the project directory?
So I have used a combination of items related to this issue. Not all of them are necessary to fix my issue but I will detail it anyway.
I added the MsBuild option from @themindfulcoder.
{
"MsBuild": {
"UseLegacySdkResolver": true
}
}
I have a global.json pinning the sdk.
{
"sdk": {
"version": "2.2.300"
}
}
I added omnishart settings to .vscode\settings.json file per @rchande in https://github.com/OmniSharp/omnisharp-vscode/issues/3102#issuecomment-500517754
{
"omnisharp.path": "latest",
"omnisharp.useGlobalMono": "never"
}
I added an environment variable.
export MSBuildSDKsPath=$HOME/dotnet/sdk/$(dotnet --version)/Sdks
I used the dotnet new react template. It did not generate a .sln file. The existence of that file made no difference.
Once adding all of these items, the extension started to function. I started to undo what I added to see what was the real solution.
The "omnisharp.path": "latest", setting is also not required.
The "MsBuild" legacy resolver is also not required.
The env variable is not necessary
"omnisharp.useGlobalMono": "never" is the solution to my issue on osx.
My Solution
"omnisharp.useGlobalMono": "never"is the solution to my issue on osx.
@steveoh Thanks a lot dude!
@nguerrera @rchande I proposed a change to how we score msbuild here https://github.com/OmniSharp/omnisharp-roslyn/pull/1545
it should prevent vs2017 to be ever selected over the bundled msbuild 16 and still allow vs2019 to be used
@James-Lester No. According to this page of Omnisharp wiki, the file omnisharp.json should be put in %USERPROFILE%/.omnisharp/.
the original issue reported here has been resolved as VS2017 msbuild is no longer going to be picked up.
also, Omnisharp has been updated to msbuild 16.3.
In C:\Users\YourUser\.omnisharp add an omnisharp.json with
{
"MsBuild": {
"UseLegacySdkResolver": true
}
}
Most helpful comment
Solved this problem by adding
omnisharp.jsonwith