Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowThis browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
When you try to use .NET on Linux, commands such as dotnet new
and dotnet run
may fail with a message related to a file not being found, such as fxr, libhostfxr.so, or FrameworkList.xml. Some of the error messages may be similar to the following items:
System.IO.FileNotFoundException
System.IO.FileNotFoundException: Could not find file '/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/5.0.0/data/FrameworkList.xml'.
A fatal error occurred.
A fatal error occurred. The required library libhostfxr.so could not be found.
or
A fatal error occurred. The folder [/usr/share/dotnet/host/fxr] does not exist.
or
A fatal error occurred, the folder [/usr/share/dotnet/host/fxr] does not contain any version-numbered child folders.
Generic messages about dotnet not found
A general message may appear that indicates the SDK isn't found, or that the package has already been installed.
One symptom of these problems is that both the /usr/lib64/dotnet
and /usr/share/dotnet
folders are on your system.
Tip
Use the dotnet --info
command to list which SDKs and Runtimes are installed. For more information, see How to check that .NET is already installed.
Important
Starting with .NET 9, Microsoft only publishes packages for supported Linux distributions that don't publish their own packages. For more information, see Install .NET on Linux.
These errors usually occur when two Linux package repositories provide .NET packages. While Microsoft provides a Linux package repository to source .NET packages, some Linux distributions also provide .NET packages. These distributions include:
If you mix .NET packages from two different sources, you'll likely run into problems. The packages might place things at different paths and might be compiled differently.
The solution to these problems is to use .NET from one package repository. Which repository to pick, and how to do it, varies by use-case and the Linux distribution.
Do you use the Microsoft repository for other packages, such as PowerShell and MSSQL?
Yes
Configure your package manager to ignore the .NET packages from the Microsoft repository. It's possible that you've installed .NET from both repositories, so you want to choose one or the other.
Remove the existing .NET packages from your distribution. You want to start over and ensure that you don't install them from the wrong repository.
sudo dnf remove 'dotnet*' 'aspnet*' 'netstandard*'
Configure the Microsoft repository to ignore .NET packages.
echo 'excludepkgs=dotnet*,aspnet*,netstandard*' | sudo tee -a /etc/yum.repos.d/microsoft-prod.repo
Reinstall .NET from the distribution's package feed. For more information, see Install .NET on Linux.
No
Remove the existing .NET packages from your distribution. You want to start over and ensure that you don't install them from the wrong repository.
sudo dnf remove 'dotnet*' 'aspnet*' 'netstandard*'
Delete the Microsoft repository feed from your distribution.
sudo dnf remove packages-microsoft-prod
Reinstall .NET from the distribution's package feed. For more information, see Install .NET on Linux.
Do you use the Microsoft repository for other packages, such as PowerShell and MSSQL?
Yes
Configure your package manager to ignore the .NET packages from the Microsoft repository. It's possible that you've installed .NET from both repositories, so you want to choose one or the other.
Remove the existing .NET packages from your distribution. You want to start over and ensure that you don't install them from the wrong repository.
sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'
Create /etc/apt/preferences
, if it doesn't already exist.
touch /etc/apt/preferences
Open /etc/apt/preferences
in an editor and add the following settings, which prevents packages that start with dotnet
, aspnetcore
, or netstandard
from being sourced from the Microsoft repository:
Package: dotnet* aspnet* netstandard*
Pin: origin "packages.microsoft.com"
Pin-Priority: -10
Reinstall .NET from the distribution's package feed. For more information, see Install .NET on Linux.
No
Remove the existing .NET packages from your distribution. You want to start over and ensure that you don't install them from the wrong repository.
sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'
Delete the Microsoft repository feed from your distribution.
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt update
Reinstall .NET from the distribution's package feed. For more information, see Install .NET on Linux.
Configure your package manager to ignore the .NET packages from the distribution's repository. It's possible that you've installed .NET from both repositories, so you want to choose one or the other.
Remove the existing .NET packages from your distribution. You want to start over and ensure that you don't install them from the wrong repository.
sudo dnf remove 'dotnet*' 'aspnet*' 'netstandard*'
Configure the Linux repository to ignore .NET packages.
echo 'excludepkgs=dotnet*,aspnet*,netstandard*' | sudo tee -a /etc/yum.repos.d/<your-package-source>.repo
Make sure to replace <your-package-source>
with your distribution's package source.
Reinstall .NET from the distribution's package feed. For more information, see Install .NET on Linux.
Configure your package manager to ignore the .NET packages from the distribution's repository. It's possible that you've installed .NET from both repositories, so you want to choose one or the other.
Remove the existing .NET packages from your distribution. You want to start over and ensure that you don't install them from the wrong repository.
sudo apt remove 'dotnet*' 'aspnet*' 'netstandard*'
Create /etc/apt/preferences
, if it doesn't already exist.
touch /etc/apt/preferences
Open /etc/apt/preferences
in an editor and add an apt preferences fragment to prevent packages that start with dotnet
, aspnetcore
, or netstandard
from being sourced from the distribution's repository.
Package: dotnet* aspnet* netstandard*
Pin: origin "<your-package-source>"
Pin-Priority: -10
Make sure to replace <your-package-source>
with your distribution's package source.
Your distribution may have more than one package source.
For example, on Ubuntu in the US, you may need to use one fragment for archive.ubuntu.com
and another for security.ubuntu.com
. Separate each fragment with a blank line like this:
Package: dotnet* aspnet* netstandard*
Pin: origin "archive.ubuntu.com"
Pin-Priority: -10
Package: dotnet* aspnet* netstandard*
Pin: origin "security.ubuntu.com"
Pin-Priority: -10
Tip
Use the apt-cache policy
command to find the source:
apt-cache policy '?name(dotnet.*)' | grep -v microsoft | grep '/ubuntu' | cut -d"/" -f3 | sort -u
Tip
If you registered the Ubuntu .NET backports package repository you should unregister the Ubuntu .NET backports package repository instead of configuring your package manager to ignore the contained .NET packages. Otherwise your package manager pulls the package index from this repository, just to ignore it, because the repository only contains .NET packages. This effectively slows down updating your local package index every time you call apt update
.
Use the apt-cache policy
command to check if you registered the Ubuntu .NET backports package repository:
apt-cache policy '?name(dotnet.*)' | grep 'ppa.launchpadcontent.net/dotnet/backports' | sort -u
Reinstall .NET from the Microsoft package feed. For more information, see Install .NET on Linux. If using Ubuntu, see My Ubuntu distribution doesn't include the .NET version I want, or I need an out-of-support .NET version.
Many other users have reported these problems. The following is a list of those issues. You can read through them for insights on what may be happening:
System.IO.FileNotFoundException and '/usr/share/dotnet/packs/Microsoft.NETCore.App.Ref/5.0.0/data/FrameworkList.xml'
Fatal error: libhostfxr.so couldn't be found
Fatal error: folder /host/fxr doesn't exist
Fatal error: folder /host/fxr doesn't contain any version-numbered child folders
Generic errors without clear messages
.NET feedback
.NET is an open source project. Select a link to provide feedback:
Events
Mar 17, 11 PM - Mar 21, 11 PM
Join the meetup series to build scalable AI solutions based on real-world use cases with fellow developers and experts.
Register nowTraining
Module
Create a new .NET project and work with package dependencies - Training
Create a .NET project and learn to add packages and manage package dependencies in your project. Use the .NET Core CLI and NuGet registry to add libraries and tools to your C# applications through Visual Studio Code.