Installing .NET 5 on Fedora: some installation gotchas
If you're a regular .NET Core user and follow Microsoft's official docs on installing .NET 5 in Fedora, you might end up running into some problems with Targeting Packs for earlier .NET Core versions.
In particular, you might get the infamous:
The framework 'Microsoft.NETCore.App', version '3.1.0' was not found.
- The following frameworks were found:
5.0.1 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]
You can resolve the problem by installing the specified framework and/or SDK.
even if you already have all of dotnet-sdk-3.1
, dotnet-runtime-3.1
and dotnet-targeting-pack-3.1
installed. This (usually) happens when your installation ends up as a mix of Fedora and Microsoft-sourced packages.
What's happening
What's causing this is essentially just different installation paths: the packages in the Microsoft repo will install the runtime and all its moving parts into /usr/share/dotnet
which is also where the dotnet
CLI will look if it comes from a Microsoft-installed package.
On the other hand, Fedora installs its dotnet-*
packages to /usr/lib64/dotnet
and will look for installed SDKs and runtimes there instead. As such, the Fedora packages will only "see" runtimes/SDKs from the Fedora packages, not the Microsoft ones.
How to fix it
There's two options here: wait or reinstall from one source. At the time of writing, .NET 5 packages aren't available in the official repos for Fedora 32, so if you only want to use 3.1 you can just hang on until .NET 5 packages land in the official repos.
If you want to play with the fun stuff in .NET 5 right away though, you can install both 3.1 and 5 from the Microsoft packages and they should see each other. First, remove your existing packages:
Then, install all the packages you need, only from the Microsoft repo, using dnf
's disablerepo
option:
You should then be able to run dotnet --info
and see both 3.1 and 5.0 SDKs/runtimes installed and available.
This should also resolve problems with global tools not running after upgrading to .NET 5