articles » current » information-technology » linux » setup-and-configure » remove-and-reinstall-dotnet

How to Remove and Reinstall .NET on Linux (Ubuntu)

"A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist." Does dotnet not work? Fully remove it from the Linux system and reinstall it to get it working again.

First, remove all the existing packages and restore the system to a clean state by issuing these three commands.

sudo apt remove dotnet*
sudo apt remove aspnetcore*
sudo apt remove netstandard*

Attempt to remove this file (should it exist):

sudo rm /etc/apt/sources.list.d/microsoft-prod.list

Issue the following two commands to use the official ubuntu package.

sudo apt update

Note that this example uses .NET 6 but later versions can be specified for the future.

sudo apt install dotnet-sdk-6.0

Now, issue this command to see if .NET is working properly.

dotnet --info

This site uses cookies. Cookies are simple text files stored on the user's computer. They are used for adding features and security to this site. Read the privacy policy.