Visual Studio Code can't locate .NET SDK

Viewed 86

OS: Ubuntu 20.04 LTS 64 bit .NET SDK version: 6.0.301 Visual Studio Code version: 1.67.2

I've downloaded .NET Core SDK from Plasma Discover and run these commands: sudo snap alias dotnet-sdk.dotnet dotnet sudo ln -s /snap/dotnet-sdk/current/dotnet /usr/local/bin/dotnet

And I Always get this error: The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path.

I've done some reinstalls, none of them worked. How to fix this?

1 Answers

I have used snap to install only preview .NET versions. I am not sure whether you have to set your DOTNET_ROOT environment variable. I see the recommended way to install .NET6 is to use

sudo apt-get update; \
  sudo apt-get install -y apt-transport-https && \
  sudo apt-get update && \
  sudo apt-get install -y dotnet-sdk-6.0

You can use dotnet --info to see which versions are installed. Once I installed 32-bit version and I received an error that the .NET6 version is not installed. The error was gone after I installed the 64-bit version.

Reference:
https://docs.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2004
https://docs.microsoft.com/en-us/dotnet/core/install/linux-snap

Related