On macOS Big Sur dotnet installed via homebrew doesn't work but does work with official installer
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
- On macOS Big Sur (M1 but don't think that matters)
- Install Visual Studio Code
- Install Homebrew
brew install dotnetdotnet new console- Open Visual Studio Code
- Install C# extension, e.g. ms-dotnettools.csharp
- 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
C# log
Environment information
VSCode version: 1.59.1 C# Extension: 1.23.14
Mono Information
OmniSharp using built-in monoDotnet Information
.NET SDK (reflecting any global.json): Version: 5.0.400 Commit: d61950f9bfRuntime 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 |
Looks similar to my issue https://github.com/OmniSharp/omnisharp-vscode/issues/4729, but I do have installed the SDK via the official installer.
@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.
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
It works for me (add to settings.json):
"dotnet.dotnetPath": "/usr/local/Cellar/dotnet/8.0.1/bin/",
"dotnet.workingWithTestSignedSdk": true