At some point my dotnet started to give me an error "Error: [/usr/share/dotnet/host/fxr] does not exist". Problem is that Ubuntu has dotnet in there repositories and if you install the Microsoft repositories at "/etc/apt/sources.list.d/microsoft-prod.list" then there is conflicting packages. And with updates the dotnet break with the error.

On my side I can't remove the Microsoft repositories at "/etc/apt/sources.list.d/microsoft-prod.list" because I install sql server tools as well.

From solutions found I had to do the following.

1. Remove the dotnet packages with the following command

sudo apt remove dotnet* aspnetcore* netstandard*

2. Create a file "99microsoft-dotnet.pref" in folder "/etc/apt/preferences.d" to tell apt to use the Microsoft packages instead of the Ubuntu packages. Put the following content in the file.

Package: *
Pin: origin "packages.microsoft.com"
Pin-Priority: 1001

3. Then install the dotnet packages again. (You can change the dotnet version to the required version.

sudo apt update && sudo apt install -y dotnet-sdk-6.0

4. For me after a period my dotnet broke again. On research I found that unattended apt upgrade do not use the Microsoft packages and then the Ubuntu versions was installed again. So to fix unattended upgrades I had to change the following file "/etc/apt/apt.conf.d/50unattended-upgrades" and add the following to the "Unattended-Upgrade::Package-Blacklist" part.

Unattended-Upgrade::Package-Blacklist
{
    "dotnet.*";
    "aspnetcore.*";
};

 Hope this helps

References:

https://stackoverflow.com/questions/73753672/a-fatal-error-occurred-the-folder-usr-share-dotnet-host-fxr-does-not-exist
https://github.com/dotnet/core/issues/7699#issuecomment-1780733437

 

Cookie policy

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Cookie Policy