Guides 11792 Published by

The article explains how to install .NET on Rocky Linux 8 or AlmaLinux 8 by adding Microsoft’s official repository and GPG key, then enabling the repo and installing either the runtime or SDK. It walks through the commands for registering the repo, choosing between dotnet-6 or dotnet-7, and verifying the installation with dotnet --info. The author also lists common pitfalls such as missing GPG keys, wrong repo names, mixing repositories, and installing multiple SDKs simultaneously, offering tips to avoid dependency problems. Finally, it encourages readers to start a new project or run existing code once the SDK is installed.



How to Install .NET on Rocky Linux 8 (or AlmaLinux 8) – Quick, Clean, and Bug‑Free

If you’re trying to run a C# API or build a cross‑platform app on your new Rocky 8 or AlmaLinux box, the first thing you’ll need is a working .NET installation. This guide walks you through adding Microsoft’s official repo, installing either the runtime or SDK, and checking that it all works—no extra fluff, just straight to the point.

Why You Need the Official Microsoft Repo

Rocky 8 and AlmaLinux 8 ship with the RHEL‑compatible package manager dnf. By default they only know about Fedora/RHEL repositories, so if you try dnf install dotnet-sdk-6.0 you'll hit a dead end. Microsoft hosts its own repo that contains all the up‑to‑date .NET packages for Linux. Skipping this step is like trying to fit a square peg into a round hole—everything else will still be out of place.

Adding Microsoft’s GPG Key

Before you can trust packages from Microsoft, dnf must know who signed them.

sudo rpm -Uvh https://packages.microsoft.com/config/centos/8/packages-microsoft-prod.rpm

Without the key, dnf will refuse to install anything from the new repo and you’ll be stuck with outdated or missing packages.

Registering the .NET Repository

After the GPG key lands in /etc/yum.repos.d/, enable the dotnet repo.

sudo dnf config-manager --set-enabled microsoft-dotnet-6

If you want a newer major version, replace dotnet-6 with dotnet-7.

The repo contains separate entries for runtimes and SDKs; enabling it tells dnf where to look.

Installing the Runtime or SDK

Decide whether you just need to run apps or develop them.

# For running .NET 6 apps only
sudo dnf install dotnet-runtime-6.0

# For building and running
sudo dnf install dotnet-sdk-6.0

If you prefer the latest LTS, swap “6.0” for “7.0”.

The runtime is lighter but can’t compile code; the SDK bundles the compiler and CLI tools.

Verifying Your Installation

Once installed, confirm everything is wired up:

dotnet --info

You should see a list of the .NET versions you have, along with your OS architecture. If you get an error like “command not found”, double‑check that /usr/bin/dotnet exists and that your PATH includes /usr/bin.

Common Pitfalls (And How to Dodge Them)
  • Forgot the GPG key: dnf install dotnet-sdk-6.0 will fail with a signature error.
  • Wrong repo name: On AlmaLinux 8 the repo is still called “microsoft-dotnet‑6”; mistyping it silences dnf.
  • Mixed RHEL/CentOS repos: Mixing CentOS and Rocky repos can lead to dependency hell; stick with what packages-microsoft-prod.rpm installs.
  • Trying to install multiple SDKs at once: If you pull both 6.0 and 7.0 SDKs, you’ll have duplicate binaries in /usr/share/dotnet. Keep only the one you need or use global.json to pin versions.

I’ve seen this happen after a bad driver update on a workstation that ended up pulling an old CentOS repository into the mix—ended up with broken dependencies and a half‑installed .NET. Keeping your repo list lean saves headaches later.

Final Thought

That’s all you need to get .NET running on Rocky 8 or AlmaLinux 8. Once the SDK is in place, you can start a new project with dotnet new console or drop into an existing repository and run tests straight away.