Install .NET 7 in Fedora 37

A few weeks ago .NET 7 was finally released by Microsoft with a lot of new features. Highly recommended is the article around the performance improvements (Performance Improvements in .NET 7) that have been made compared to .NET 6.0.

This post is not primarily about what new features .NET 7.0 brings, but more about how to install the latest runtime from microsoft on fedora. Unfortunately, only .NET 6.0 can be installed via dnf. .NET 7.0 is still completely missing from the package sources.

The official documentation for .NET 7.0 and fedora only shows the not much meaningful information (Supported Version):

.NET 7 isn’t yet ready for Fedora. This article will be updated when it’s available.

whatever that means

This article is a kind of continuation of my last article about Use .NET 7 with Fedora 36 and Distrobox and describes the installation of .NET 7.0 on Fedora 37. The same procedure should most likely work for Fedora 36/35 as well.

Setup

First, head over to the official .NET 7.0 download page and select dotnet-install scripts or use wget to download the official dotnet-install.sh script.

wget https://dotnet.microsoft.com/download/dotnet/scripts/v1/dotnet-install.sh
chmod +x ./dotnet-install.sh

The installation is pretty much straightforward. Just define the specific major version with the –channel parameter to indicate a specific version. The following command installs the .NET 7.0 SDK on your computer.

./dotnet-install.sh --channel 7.0

All necessary bits and bytes are installed by default under ~/.dotnet.

ls -l ~/.dotnet
drwxr-xr-x. 1 stef stef     24 15. Nov 20:07 corefx
drwxr-xr-x. 1 stef stef      6  7. Dez 21:04 host
drwxr-xr-x. 1 stef stef      0  8. Dez 20:52 metadata
drwxr-xr-x. 1 stef stef    224  7. Dez 21:04 packs
drwxr-xr-x. 1 stef stef     28  7. Dez 21:16 sdk
drwxr-xr-x. 1 stef stef     28  7. Dez 21:07 sdk-advertising
drwxr-xr-x. 1 stef stef     52  7. Dez 21:16 sdk-manifests
drwxr-xr-x. 1 stef stef     90  7. Dez 21:04 shared
drwxr-xr-x. 1 stef stef   6300 27. Nov 19:00 symbolcache
drwxr-xr-x. 1 stef stef   3774  8. Dez 20:52 TelemetryStorageService
drwxr-xr-x. 1 stef stef     22  7. Dez 21:16 templates
drwxr-xr-x. 1 stef stef    112 27. Nov 18:55 tools
-rwxr-xr-x. 1 stef stef 175832  7. Dez 21:04 dotnet

Once the installation has been completed successfully, two environment variables must be set so that the SDK can be accessed correctly from the console. In your .bashrc set the following two environment variables:

export DOTNET_ROOT=$HOME/.dotnet
export PATH=$DOTNET_ROOT:$PATH:$DOTNET_ROOT/tools

DOTNET_ROOT variable is set to the folder .NET was installed to. And PATH should include both the DOTNET_ROOT folder and the user’s .dotnet/tools folder.

The correct installation can be checked relatively easily with the help of the dotnet command line tool:

dotnet --info

Runtime Environment:
 OS Name:     fedora
 OS Version:  37
 OS Platform: Linux
 RID:         fedora.37-x64
 Base Path:   /home/stef/.dotnet/sdk/7.0.100/

.NET SDKs installed:
  6.0.403 [/home/stef/.dotnet/sdk]
  7.0.100 [/home/stef/.dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 6.0.11 [/home/stef/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 7.0.0 [/home/stef/.dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 6.0.11 [/home/stef/.dotnet/shared/Microsoft.NETCore.App]
  Microsoft.NETCore.App 7.0.0 [/home/stef/.dotnet/shared/Microsoft.NETCore.App]

Environment variables:
  DOTNET_ROOT       [/home/stef/.dotnet]

JetBrains Rider

In Rider I had the problem that the SDK was not recognized. However, this can be fixed without much effort. Under File -> Settings go to Build, Execution, Deployment and select Toolset and Build.

.NET 7.0 CLI executable path

Now change the .NET CLI executable path so that it matches your own installation.