OmniSharp / omnisharp-roslyn

OmniSharp server (HTTP, STDIO) based on Roslyn workspaces
MIT License
1.78k stars 419 forks source link

Fails to load a project that uses an additional SDK reference #1138

Open DustinCampbell opened 6 years ago

DustinCampbell commented 6 years ago

From @timjroberts on March 19, 2018 20:21

The extension fails to load .csproj files where additional SDKs have been specified as per the MSBUILD 15.6 "Sdk" Design concept.

Environment data

dotnet --info output:

.NET Command Line Tools (2.1.300-preview1-008174)

Product Information:
 Version:            2.1.300-preview1-008174
 Commit SHA-1 hash:  b8df89a54f

Runtime Environment:
 OS Name:     Mac OS X
 OS Version:  10.13
 OS Platform: Darwin
 RID:         osx.10.12-x64
 Base Path:   /usr/local/share/dotnet/sdk/2.1.300-preview1-008174/

Microsoft .NET Core Shared Framework Host

  Version  : 2.1.0-preview1-26216-03
  Build    : f2c3216183d20416568a4bbf5bb7d153e826f153

VS Code version: 1.21.1 C# Extension version: 1.14.0

Steps to reproduce

Create a .csproj file that references an additional SDK. In my particular example, I have:

<Project Sdk="Microsoft.NET.Sdk;TypeScript.Sdk">
    ....
</Project>

In this example, TypeScript.Sdk has been manually installed into the SDK base path (identified in the dotnet --info output above), however, I've also tried using TypeScript.Sdk/1.0.0 which should prompt the NuGet resolver in MSBUILD to download and make the SDK available.

Expected behavior

The project should load successfully and code-lens/autocompletion support work as normal.

Actual behavior

I receive the following output in the Output window:

[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/timroberts/test3/Core/Core.csproj
Can't find custom attr constructor image: /usr/local/share/dotnet/sdk/2.1.300-preview1-008174/Sdks/TypeScript.Sdk/lib/netstandard2.0/TypeScript.Sdk.Tasks.dll mtoken: 0x0a00000a due to: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. assembly:netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 type:<unknown type> member:<none>

At that point I receive no code-lens or autocompletion support for any project in the solution.

Running dotnet build works as expected, and the SDKs are executed as intended.

Copied from original issue: OmniSharp/omnisharp-vscode#2124

DustinCampbell commented 6 years ago

FWIW, there is often a lag between when a feature appears in a nightly preview of the .NET Core SDK and when it appears in OmniSharp.

natemcmaster commented 6 years ago

By the way, additional SDKs is supported in VS 15.6 and the 2.1.105 SDK. This isn't a preview feature anymore.

DustinCampbell commented 6 years ago

Sure. I understand. However, as OmniSharp is a community project, it necessarily lags a bit. If you're interested in seeing it updated at a faster rate, do feel free to pitch in with PRs! :smile:

natemcmaster commented 6 years ago

Sorry if my last comment seemed whiny. I was just trying to point out that it affects users on stable releases, not just previews.

Would be happy to contribute more as time allows. I've hunting through the code and trying to figure out why this happens. I haven't found the cause yet.

DustinCampbell commented 6 years ago

I did find the cause. It's due to a hack we left in OmniSharp due to the SDK resolvers not being able to support .NET Core SDKs <= 1.0.3. I'm removing the hack. :smile: