vscode-csharp: The .NET Core SDK cannot be located

Environment data

dotnet --info output: It was not possible to find any installed .NET Core SDKs Did you mean to run .NET Core SDK commands? Install a .NET Core SDK from: https://aka.ms/dotnet-download

Host (useful for support): Version: 3.0.0 Commit: 95a0a61858

.NET Core SDKs installed: No SDKs were found.

.NET Core runtimes installed: Microsoft.NETCore.App 3.0.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.0.0 [C:\Program Files (x86)\dotnet\shared\Microsoft.WindowsDesktop.App]

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

VS Code version: 1.40

C# Extension version: 1.21.6

Steps to reproduce

Expected behavior

VScode find .net core sdk

Actual behavior

VScode can’t find .net core sdk but i installed it 11

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 28 (4 by maintainers)

Most upvoted comments

Environment

  • .NET Core SDK 3.1
  • VSCode C# Extension 1.21.9
  • Mac

Reference

OmniSharp/omnisharp-vscode Wiki

If you had Visual Studio Code open at the time you installed the .NET SDK, and you haven't restarted it, you should do so.

My Solution

Exit VSCode and open it…

Reason

I try not to exit vscode on my mac when it’s connected to a monitor because vscode has some GPU rendering problem in this circumstances. This habbit leads to the problems.

If there’s still people having this issue then try this:

  1. From start menu search for “this pc”, right click and select properties.
  2. Click Advanced system settings
  3. Click on “Environment Variables…”
  4. Select either the Users or Systems “Path” variable and click Edit…
  5. In either of them you should find the path to your “dotnet” folder

now in my case I had 2 C:\Program Files (x86)\dotnet\ and C:\Program Files\dotnet\ if you actually go to the folders you’ll notice that there’s no sdk folder within the C:\Program Files (x86)\dotnet\ folder. So simply select C:\Program Files\dotnet\ and click the “move up” button. Then click OK all the way out of there, now try and see if things are working…

Please, don’t install the 3.0-rc1 SDK – that is an outdated release candidate.

@GhostShot3 the output you have from above indicates that the C# extension is working correctly - you don’t have a .NET SDK installed, just a .NET runtime. Did you install an SDK? Here is the current install link from https://dotnet.microsoft.com/learn/dotnet/hello-world-tutorial/install

Installation For anyone running into issues, do the following method, which will work on all distributions and has been tested with automation/provisioning tools:

If you run into issues, please check your distro’s required dependencies here: https://learn.microsoft.com/en-us/dotnet/core/install/linux-scripted-manual#dependencies https://github.com/dotnet/core/blob/main/release-notes/8.0/linux-packages.md

sh -c "$(curl -fsSL https://dot.net/v1/dotnet-install.sh)" Follow the prompts until the installation is complete. This will be installed on your home path.

or

Just download and extract to ~/.dotnet from https://dotnet.microsoft.com/en-us/download/dotnet/8.0

Now, vscode needs to be able to find just the dotnet binary at /usr/share/dotnet else you will get an error.

Let’s go ahead and create a soft link

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

Optionally copy the directory to the /usr/share/dotnet path for multi-user support when provisioning.

sudo mkdir -p /usr/share/dotnet
sudo cp -R ~/.dotnet/* /usr/share/dotnet/
sudo chown -R root:root /usr/share/dotnet

You will want to create the export regardless, especially the tools path, since you’ll want to install some nugpkgs.

You can create your dotnet alias and tools export on either ~/.bashrc or ~/.zshrc (Yes, an alias, since the soft link will always assume priority, and you will have workload installs going to the root user instead of your own user - among other nupkg breaks and repairs) code ~/.zshrc Append the following two lines

export DOTNET_ROOT=$HOME/.dotnet
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

Finally, save the file and source it so you don’t have to logout/reboot source ~/.zshrc

Optionally append the following exports for multi-user provisioning at /etc/profile.local (don’t edit /etc/profile - changes will be lost after updates/upgrades). Reboot once done for the changes to take effect.

export DOTNET_ROOT=/usr/share/dotnet/
export PATH=$PATH:$DOTNET_ROOT:$DOTNET_ROOT/tools

.Net Uninstall Tool If you are like me and have to manage various versions of .Net, you will want to have the uninstall tool, making it easier to manage versions not wanted in the future.

https://github.com/dotnet/cli-lab/releases

Testing! You can use one of the guides provided to create a new project and ensure you don’t get any errors with dependencies or other issues.

I 100% recommend test-driving it with the following two quick projects:

https://dotnet.microsoft.com/en-us/learn/dotnet/hello-world-tutorial/intro https://dotnet.microsoft.com/en-us/learn/aspnet/blazor-tutorial/intro

BONUS: Testing with the OpenSource MonoGame Framework! (A Microsoft XNA Fork) Personally, I needed to publish a game ASAP and ran into this horrible issue. Here is another quick project you can use to test using the monogame framework:

dotnet new --install MonoGame.Templates.CSharp
mkdir -p ~/csharp_projects
dotnet new mgdesktopgl -o ~/csharp_projects/monogamedev

Up to this point, you should be able to launch the asset/content builder mgcb-editor just for testing purposes from inside the root of the project folder we just created:

cd ~/csharp_projects/monogamedev
dotnet mgcb-editor

Now, let’s pretend we are publishing: dotnet publish -c Release -r linux-x64 /p:PublishReadyToRun=false /p:TieredCompilation=false --self-contained

Launch the game ~/csharp_projects/monogamedev/bin/Release/net6.0/linux-x64/publish/monogamedev

You should get an empty game canvas from the monogame framework running.

If your project or environment gets messed up at any point, restore it. dotnet restore

Reference: https://monogame.net/articles/getting_started/1_setting_up_your_development_environment_unix/

Happy Coding! and/or Automated provisioning!

Just wanted to chime in and say I saw the same problem, with the same resolution.

In my case, I uninstalled several things (.NET Core 2.2.7, .NET Core 3.0, NuGet, Mono) and reinstalled just the .NET Core 3.0. That seemed to resolve the problem.

It looks like VSCode was picking up the MSBuild/etc. from the Mono folder (mine was Mono 6.0 for some reason), but anyway, reinstall for the win.

(I’m on Linux if that matters)