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

OmniSharp doesn't work with latest .NET 6 SDK #17718

Closed
richlander opened this issue May 19, 2021 · 10 comments
Closed

OmniSharp doesn't work with latest .NET 6 SDK #17718

richlander opened this issue May 19, 2021 · 10 comments
Milestone

Comments

@richlander
Copy link
Member

richlander commented May 19, 2021

I tried .NET 6 Preview 5 and 6, on Windows and macOS. I get this error in the O# logs. As a result, I cannot use VS Code for C#.

Microsoft.Build.Exceptions.InvalidProjectFileException: The SDK 'Microsoft.NET.SDK.WorkloadAutoImportPropsLocator' specified could not be found.  C:\Program Files\dotnet\sdk\6.0.100-preview.5.21269.7\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.ImportWorkloads.props

Is this an O# or SDK issue?

No repro in VS 16.10 P4.

@dotnet-issue-labeler dotnet-issue-labeler bot added the untriaged Request triage from a team member label May 19, 2021
@dotnet-issue-labeler
Copy link

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@richlander
Copy link
Member Author

Related: dotnet/core#6278

@snickler
Copy link

From what I've been testing, the issue is with the Microsoft.DotNet.MSBuildSdkResolver.dll from .NET 6 Preview 3

OmniSharp/omnisharp-roslyn#2134

I can make things run again by using an older version of the MSBuildSDKResolver

@richlander
Copy link
Member Author

/cc @rainersigwald

@richlander
Copy link
Member Author

Are there test cases for this? I ran into this a couple years ago, too. I've seen plenty of other folks filing issues on this on GH and SO.

Example: dotnet/vscode-csharp#2937

@snickler
Copy link

snickler commented May 23, 2021

I have it working with a later MSBuildSdkResolver.

  1. Download and extract the latest omnisharp-roslyn release for your OS-arch and extract it to a directory
  2. Grab Microsoft.DotNet.MSBuildSdkResolver 6.0.100-preview.4.21254.26 from the dnceng Azure Artifacts
  3. Extract the contents from lib/net472/ inside the NuGet package to .msbuild/Current/Bin/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver inside of the directory where OmniSharp is extracted.
  4. Edit the Omnisharp VSCode plugin settings and set "omnisharp.path": "path-to-omnisharp\\omnisharp.exe",
  5. Restart the Omnisharp extension
  6. Enjoy

@rainersigwald rainersigwald changed the title O# doesn't work with latest .NET 6 SDK OmniSharp doesn't work with latest .NET 6 SDK May 24, 2021
@rainersigwald
Copy link
Member

This is an OmniSharp issue. It packages tools including the .NET SDK resolver that's used to import the .NET SDK. The .NET 6 SDK is configured so that it can be loaded only in MSBuild 16.10 and newer, but there were "MSBuild 16.10.0-preview" releases that go with Microsoft.DotNet.MSBuildSdkResolver versions that needed some work to actually work, so that block isn't working in OmniSharp at the moment. dotnet/core#6278 (comment)

One thing I'm confused by though @richlander--on Windows, OmniSharp should default to using a Visual Studio copy of MSBuild and so not hit this if you have a VS installed. For instance in my log (toward the very top):

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 5 MSBuild instance(s)
            1: Visual Studio Enterprise 2017 15.9.28307.1525 - "C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\MSBuild\15.0\Bin"
            2: Visual Studio Enterprise 2022 17.0.31324.12 - "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin"
            3: Visual Studio Enterprise 2019 16.11.31320.298 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin"
            4: Visual Studio Enterprise 2019 16.9.31313.79 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin"
            5: StandAlone 16.9.0 - "c:\Users\raines\.vscode\extensions\ms-dotnettools.csharp-1.23.11\.omnisharp\1.37.8\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Enterprise 2022 17.0.31324.12 - "C:\Program Files\Microsoft Visual Studio\2022\Preview\MSBuild\Current\Bin"

Are you seeing otherwise? That might be an unrelated O# issue.

@snickler
Copy link

The more I think about it, the more I believe this issue is something likely to occur with Win Arm64 devices and Linux/macOS.

On Win Arm64 VSCode, it fails to resolve MSBuild instances except for the Standalone (even though the OmniSharp executable and OmniSharp.MSBuild.dll are .NET 4.7.2 and I have the latest VS 2019 Enterprise Preview installed).

@richlander
Copy link
Member Author

@rainersigwald -- I thought it wasn't working on my Windows machine, but it looks good now. Must be my macOS machine only. I updated VS during this same experience, so it's possible that new bits came down that improved the situation after I tried O#.

[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Visual Studio Community 2019 16.10.31313.381 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin"
            2: StandAlone 16.9.0 - "c:\Users\rich\.vscode\extensions\ms-dotnettools.csharp-1.23.11\.omnisharp\1.37.8\.msbuild\Current\Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Visual Studio Community 2019 16.10.31313.381 - "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\MSBuild\Current\Bin"

I think you are right that this is an O# issue and it's msbuild is too old.

/cc @JoeRobich @cartermp

@marcpopMSFT marcpopMSFT self-assigned this May 25, 2021
@marcpopMSFT marcpopMSFT removed their assignment May 25, 2021
@marcpopMSFT marcpopMSFT removed the untriaged Request triage from a team member label May 25, 2021
@marcpopMSFT marcpopMSFT added this to the 6.0.1xx milestone May 25, 2021
@marcpopMSFT
Copy link
Member

Closing as this is tracked in this issue: dotnet/core#6278

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

No branches or pull requests

4 participants