PROWAREtech

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.

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

Attempt to remove this file (should it exist):

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

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

bash
sudo apt update

Note that this example uses .NET 8 but later versions can be specified for the future. If a version of the SDK was just released then Ubuntu may not have updated their repository with the latest version; using the Ubuntu Software app to install the .NET SDK is not recommended.

bash
sudo apt install dotnet-sdk-8.0

If the above command does not work, try these three commands replacing the 22.04 with the Ubuntu version being used:

bash
wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
bash
sudo dpkg -i packages-microsoft-prod.deb
bash
rm packages-microsoft-prod.deb

Then issue this command replacing the sdk version with the latest version available:

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

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

bash
dotnet --info

PROWAREtech

Hello there! How can I help you today?
Ask any question

PROWAREtech

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.
ACCEPT REJECT