Solvedomnisharp vscode The SDK 'Microsoft.NET.Sdk.Web' specified could not be found.

Was asked to create new issue on #2876

Environment data

dotnet --info output:

PS C:\source\poc\omnisharp-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 Files\dotnet\sdk\2.2.203\

Host (useful for support):
Version: 2.2.4
Commit: f95848e524

.NET Core SDKs installed:
1.0.0 [C:\Program Files\dotnet\sdk]
1.0.1 [C:\Program Files\dotnet\sdk]
1.0.4 [C:\Program Files\dotnet\sdk]
2.0.0 [C:\Program Files\dotnet\sdk]
2.0.2 [C:\Program Files\dotnet\sdk]
2.1.4 [C:\Program Files\dotnet\sdk]
2.1.300 [C:\Program Files\dotnet\sdk]
2.1.302 [C:\Program Files\dotnet\sdk]
2.2.104 [C:\Program Files\dotnet\sdk]
2.2.203 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 1.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 1.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs:
https://aka.ms/dotnet-download

VS Code version:

1.33.1

C# Extension version:

ms-vscode.csharp-1.19.0.omnisharp\1.32.18

Steps to reproduce

Created a new .NET Core project based on 2.2.203
Repo that gives me issue - https://github.com/tonyranieri/omnisharp-poc

Expected behavior

I don't get the exception and the project loads.

Actual behavior

Exception when loading, no OmniSharp functionality.

Error Log

If I pin the version to 2.2.104 via the global.json and reload VS Code it works as expected.

13 Answers

✔️Accepted Answer

Solved this problem by adding omnisharp.json with

{
    "MsBuild": {
        "UseLegacySdkResolver": true
    }
}

Other Answers:

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 #3102 (comment)

{
   "omnisharp.path": "latest",
   "omnisharp.useGlobalMono": "never"
}

I added an environment variable.

export MSBuildSDKsPath=$HOME/dotnet/sdk/$(dotnet --version)/Sdks

The project

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

My Solution

"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!

More Issues: