vscode-csharp: The SDK 'Microsoft.NET.Sdk' specified could not be found.
Couldn’t get the (latest) C# extension to work correctly on one of my machines. The project is a .NET Core 3.0 dotnet new console
project with no changes.
Here are the logs: https://gist.github.com/richlander/9931ebb3c3570615439fe0ccf3ae6657
The logs demonstrate the machine env, launch code and then show the O# logs that I saw, rinse and repeat. I tried various suggestions I found @ https://github.com/Microsoft/msbuild/issues/2532
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 9
- Comments: 37 (6 by maintainers)
Don’t ask me where I found this, but the following command has fixed the issue for me (probably worth a try):
dotnet nuget locals all -c
I also have added this to my omnisharp.json:
Gold luck
I found this to be a problem when I installed dotnet via HomeBrew on mac. Uninstalled that, then used the normal installer from https://aka.ms/dotnet-download
I see that this issue is closed, but clearly is still happening using the latest version, can it please be reopened?
@trampster
you could try adding omnisharp.json file:
and see if it helps. If it doesn’t please post your OmniSharp log.
where is omnisharp.json? my ~/.omnisharp/ folder is empty… should it be? I created the omnisharp.json file and it fixed the problem.
I assume this means that the current SdkResolver is broken… is there a fix coming? when is it safe to remove the UseLegacySdkResolver setting?
Installing Visual Studio 2019 and opening my
.sln
in Visual Studio 2019 fixed the problem for me.@richlander The issue does still happen in latest version 1.19.1. I created a new program with
dotnet new console
and loaded the directory in vscode.OmniSharp Log:
My project file looks like this:
More meta, it turns out that O# needs to carry the 16.x version of either the resolver or msbuild in order to correctly work with .NET Core 3.0. This is only a problem on machines without VS 16 (which is a lot of cases). We’re hoping to get this fixed in the same timeframe as .NET Core 3.0 Preview 4.
Having the same problem on Windows 10 with Omnisharp v1.34.3 and .NET Core 3.0. Adding
"UseLegacySdkResolver": true
to myomnisharp.json
file fixed the issue.@niikoo if you are having troubles, please post your log and open a new issue. There are plenty of unrelated reasons that can cause the SDK to not be found - depending on the combination of OS, SDK version, OmniSharp configuration, usage of global vs local Mono and so on. Additionally, the SDK is a moving target because the minimal MSBuild requirement keeps changing so OmniSharp has to constantly be playing catch up game.
For example the original reason why this issue was opened has been addressed by moving to newer bundled MSBuild
@adam-becker the root cause of the issues with the 3.1.401 SDK is that it has a minimum MSBuild version of 16.7. The current stable and preview Mono releases only include 16.6.
Please try the 1.23.0 pre-release build (https://github.com/OmniSharp/omnisharp-vscode/releases/tag/v1.23.0) of the C# extension as it ships with a custom package of Mono and MSBuild that is a supported version. Note you may need to set “useGlobalMono” to “never” so that the included Mono is used instead of a system install.
This issue should be reopened, as it’s still happening as of today. If the legacy SDK resolver can find the correct SDK, then why does the current one have issues?
Fixed for me too.
File location on
Windows
isC:\Users\%USERNAME%\.omnisharp\
. The folder was empty in my case so just createdomnisharp.json
@TheSimpleZ From the logs, your sdk was installed via snap and we have an issue with SDK resolution there.
https://github.com/dotnet/cli/issues/12110 tracks the fix
https://github.com/OmniSharp/omnisharp-vscode/issues/3160#issuecomment-517057835 has a workaround.
I have the same problem on Ubuntu 19.04, using dotnet 3.0.100-preview7-012821. I made a project using
dotnet new webapi
and opened it in VSCode.Here are the logs and system info: https://gist.github.com/TheSimpleZ/27a8f1de06c52fe6223f7116714a941d