Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. #3023

Closed
tonyranieri opened this issue Apr 25, 2019 · 12 comments
Closed

The SDK 'Microsoft.NET.Sdk.Web' specified could not be found. #3023

tonyranieri opened this issue Apr 25, 2019 · 12 comments

Comments

@tonyranieri
Copy link

tonyranieri commented Apr 25, 2019

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.

@nguerrera
Copy link

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.

@nguerrera
Copy link

Also, it's confusing that (2) is described as StandAlone 15.0 instead of StandAlone 16.0.

@filipw
Copy link
Contributor

filipw commented Apr 29, 2019

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

@rchande
Copy link

rchande commented Apr 29, 2019

I think @akshita31 filed a bug for us to track enabling a choice?

@themindfulcoder
Copy link

Solved this problem by adding omnisharp.json with

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

@James-Lester
Copy link

@themindfulcoder Do you mean that file should be added to the project directory?

@steveoh
Copy link
Contributor

steveoh commented Jul 2, 2019

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.

@johankvint
Copy link

johankvint commented Jul 8, 2019

My Solution

"omnisharp.useGlobalMono": "never" is the solution to my issue on osx.

@steveoh Thanks a lot dude!

@filipw
Copy link
Contributor

filipw commented Jul 8, 2019

@nguerrera @rchande I proposed a change to how we score msbuild here OmniSharp/omnisharp-roslyn#1545
it should prevent vs2017 to be ever selected over the bundled msbuild 16 and still allow vs2019 to be used

@prodehghan
Copy link

@James-Lester No. According to this page of Omnisharp wiki, the file omnisharp.json should be put in %USERPROFILE%/.omnisharp/.

@filipw
Copy link
Contributor

filipw commented Oct 5, 2019

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.

@filipw filipw closed this as completed Oct 5, 2019
@facupm
Copy link

facupm commented May 28, 2020

In C:\Users\YourUser\.omnisharp add an omnisharp.json with

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants