vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

On macOS Big Sur dotnet installed via homebrew doesn't work but does work with official installer

Open TravisTheTechie opened this issue 4 years ago • 4 comments

Issue Description

OmniSharp says it can't find the SDK (e.g. similar to https://github.com/OmniSharp/omnisharp-vscode/issues/2937) when using homebrew installed dotnet.

Steps to Reproduce

  1. On macOS Big Sur (M1 but don't think that matters)
  2. Install Visual Studio Code
  3. Install Homebrew
  4. brew install dotnet
  5. dotnet new console
  6. Open Visual Studio Code
  7. Install C# extension, e.g. ms-dotnettools.csharp
  8. Open up the project folder

And now Omnisharp says it can't load the project.

Expected Behavior

Omnisharp loads the project. It does work if you remove the dotnet via homebrew and use the official installer. It would be good to detect this case and notify the user or allow it work. It took a lot of googling and reading through long issues to find the fix.

Actual Behavior

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

Logs

OmniSharp log

Post the output from Output-->OmniSharp log here

C# log

Post the output from Output-->C# here

Environment information

VSCode version: 1.59.1 C# Extension: 1.23.14

Mono Information OmniSharp using built-in mono
Dotnet Information .NET SDK (reflecting any global.json): Version: 5.0.400 Commit: d61950f9bf

Runtime Environment: OS Name: Mac OS X OS Version: 11.0 OS Platform: Darwin RID: osx.11.0-x64 Base Path: /usr/local/share/dotnet/sdk/5.0.400/

Host (useful for support): Version: 5.0.9 Commit: 208e377a53

.NET SDKs installed: 5.0.400 [/usr/local/share/dotnet/sdk]

.NET runtimes installed: Microsoft.AspNetCore.App 5.0.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 5.0.9 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]

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

Visual Studio Code Extensions
Extension Author Version
csharp ms-dotnettools 1.23.14
write-good-linter travisthetechie 0.1.4

TravisTheTechie avatar Aug 30 '21 02:08 TravisTheTechie

Looks similar to my issue https://github.com/OmniSharp/omnisharp-vscode/issues/4729, but I do have installed the SDK via the official installer.

Banyc avatar Aug 30 '21 09:08 Banyc

@TravisTheTechie May be a similar issue to installing via the Snap installer. This is the suggested way to resolve the snap installer issue. You will likely need to adjust file paths to match the location that brew installs dotnet.

I was struggling with omnisharp not resolving the dotnet-sdk snap on 20.04 until I discovered that a simple

ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet>

did the trick. No need for msbuild path exports or an omnisharp json legacy resolver.

JoeRobich avatar Aug 30 '21 17:08 JoeRobich

I installed dotnet via the official installer and @JoeRobich's solution worked. What I did was,

ln -s /usr/local/share/dotnet/dotnet /usr/local/bin/dotnet

macOS Big Sur 11.6 and C# Extension v1.23.15

at6ue avatar Oct 02 '21 07:10 at6ue

It works for me (add to settings.json):

    "dotnet.dotnetPath": "/usr/local/Cellar/dotnet/8.0.1/bin/",
    "dotnet.workingWithTestSignedSdk": true

AShim3D avatar Feb 29 '24 18:02 AShim3D