Why is the .NET SDK not found after installation on Ubuntu 22.04?

451 Views Asked by At

I'm trying to install the .NET SDK on my Ubuntu 22.04 system, but I'm running into some issues. After following the installation steps, I can't seem to find the SDK anywhere on my system. Here's what I've done so far:

  1. I removed any existing .NET packages with the following command:
sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'

This seemed to remove the existing .NET SDK 7.0 and other related packages.

  1. I then checked if the SDK was removed:
ls /usr/lib/dotnet/dotnet
ls /usr/lib/dotnet/

Both commands confirmed that the SDK was not present.

  1. Finally, I tried to reinstall the SDK:
sudo apt-get update && \
sudo apt-get install -y dotnet-sdk-7.0

The installation seemed to go smoothly, but when I checked again, the SDK was still not found.

dotnet --list-sdks shows nothing, dotnet --help works and shows the help menu. dotnet --version gives this message:

dotnet --version
The command could not be loaded, possibly because:
  * You intended to execute a .NET application:
      The application '--version' does not exist.
  * You intended to execute a .NET SDK command:
      No .NET SDKs were found.

Download a .NET SDK:
https://aka.ms/dotnet/download

Learn about SDK resolution:
https://aka.ms/dotnet/sdk-not-found

list runtimes worked:

dotnet --list-runtimes
Microsoft.AspNetCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.11 [/usr/lib/dotnet/shared/Microsoft.NETCore.App]

And the directories were rebuilt:

ls /usr/lib/dotnet/
dotnet  host  LICENSE.txt  packs  shared  ThirdPartyNotices.txt

ls /usr/lib/dotnet/dotnet
/usr/lib/dotnet/dotnet

ls /usr/lib/dotnet/shared
Microsoft.AspNetCore.App  Microsoft.NETCore.App

I'm not sure what I'm missing here. Why is the SDK not showing up after installation? Any help would be greatly appreciated.

Here is my release:

lsb_release -a
No LSB modules are available.
Distributor ID: Pop
Description:    Pop!_OS 22.04 LTS
Release:    22.04
Codename:   jammy
1

There are 1 best solutions below

0
Frank On

To find the SDK I ran

find / -name dotnet

Then I looked into the directories shown in the response. I found the SDK in /usr/share/dotnet.

ls /usr/share/dotnet
sdk  sdk-manifests  templates

ls /usr/share/dotnet/sdk
7.0.401

Next, I found the dotnet executable with:

which dotnet
/usr/bin/dotnet

/usr/bin/dotnet ended up being a symbolic link to /lib/dotnet/dotnet.

Since dotnet executable was in a different location than the SDK, I made a new symbolic link of the SDK diriectory and placed it in the /lib/dotnet directory

sudo ln -s /usr/share/dotnet/sdk /lib/dotnet/sdk

Now dotnet --list-sdks works correctly:

dotnet --list-sdks
7.0.401 [/usr/lib/dotnet/sdk]

Finally, I was able to use dotnet run to start my application.