Ruud van Falier
Ruud van Falier

Reputation: 8877

C# Dev Kit (VS Code) on macOS: "Compatible .NET SDK was not found"

I'm trying to use the C# Dev Kit extension for Visual Studio Code for my project.
I've created two ASP.NET Core Web API projects.

They can both be built successfully. However, when my workspace is loaded, the Solution Explorer will give an error for each project: A compatible .NET SDK was not found.

Looking at the output window, it looks like it found the SDK and I'm also able to built both projects just fine.
It looks like it's just an issue with the Solution Explorer.

I've also tried to add different project types (Class Library, Console App) but they all give the same error.

Anyone know what the problem is here?

Here is a screenshot of what I'm looking at:

enter image description here

Upvotes: 10

Views: 7318

Answers (2)

starball
starball

Reputation: 50014

This seems to be this bug: [BUG] "A compatible .NET SDK was not found" when opening workspace #120. The maintainers commented:

YuuliaKovalova:

The issue was addressed in the scope of dotnet/msbuild#9038

You can use the package with the fix https://www.nuget.org/packages/Microsoft.Build.Locator/1.6.1.

Lifeng Lu:

There are problems in the Build.Locator which broke SDK resolver in Mac under various installations, including using brew, or even without it on X64 Mac machine with older Mac OS. It has been fixed in the package, and a new update of the C# Dev Kit extension will carry it (it will be in the next pre-release, as we need give some short time to be tested).

Older answer

A fix has been released for that issue in pre-release v0.2.70. Try that out and see if that fixes your issue (source). Also related: https://github.com/dotnet/msbuild/issues/9038, the fix for which is in Microsoft.Build.Locator/1.5.6.

If the fix doesn't work for you and you're on macOS, some macOS users have said that uninstalling the HomeBrew version of dotnet and installing using the pkg file resolved their issue (source). Another user found a workaround here involving copying a dylib to a searched folder.

Upvotes: 1

Ruud van Falier
Ruud van Falier

Reputation: 8877

This is only an issue on Mac OS.

I was using Homebrew to install the .NET Core SDK.
Due to some issue, the VS Code extension was therefore not able to properly locate the SDK.

After uninstalling the SDK using Homebrew, I re-installed it using the .pkg package from Microsoft and that worked.

Upvotes: 1

Related Questions