CentOS 7 Package Manager - Install .NET Core

Package manager installs are only supported on the x64 architecture. Other architectures, such as ARM, must manually install the .NET Core SDK or manually install the .NET Core Runtime. For more information, see .NET Core dependencies and requirements.

This article describes how to use a package manager to install .NET Core on CentOS 7.

Install the SDK (which includes the runtime) if you want to develop .NET Core apps. Or, if you only need to run apps, install the runtime. If you're installing the runtime, we suggest you install the ASP.NET Core runtime, as it includes both .NET Core and ASP.NET Core runtimes.

If you've already installed the SDK or runtime, use the dotnet --list-sdks and dotnet --list-runtimes commands to see which versions are installed. For more information, see How to check that .NET Core is already installed.

Add Microsoft repository key and feed

Before installing .NET, you'll need to:

  • Add the Microsoft package signing key to the list of trusted keys.
  • Add the repository to the package manager.
  • Install required dependencies.

This only needs to be done once per machine.

Open a terminal and run the following command.

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

Install the .NET Core SDK

Update the products available for installation, then install the .NET Core SDK. In your terminal, run the following command.

sudo yum install dotnet-sdk-3.1

Install the ASP.NET Core runtime

Update the products available for installation, then install the ASP.NET runtime. In your terminal, run the following command.

sudo yum install aspnetcore-runtime-3.1

Install the .NET Core runtime

Update the products available for installation, then install the .NET Core runtime. In your terminal, run the following command.

sudo yum install dotnet-runtime-3.1

How to install other versions

The packages added to the package manager feeds are named in a hackable format: {product}-{type}-{version}.

  • product
    The type of .NET product to install. Valid options are:

    • dotnet
    • aspnetcore
  • type
    Chooses the SDK or the runtime. Valid options are:

    • sdk
    • runtime
  • version
    The version of the SDK or runtime to install. This article will always give the instructions for the latest supported version. Valid options are any released version, such as:

    • 3.1
    • 3.0
    • 2.1

    It's possible the SDK/runtime you're trying to download is not available for your Linux distribution. For a list of supported distributions, see .NET Core dependencies and requirements.

Examples

  • Install the ASP.NET Core 3.1 runtime: aspnetcore-runtime-3.1
  • Install the .NET Core 2.1 runtime: dotnet-runtime-2.1
  • Install the .NET Core 3.1 SDK: dotnet-sdk-3.1

Package missing

If the package-version combination doesn't work, it's not available. For example, there isn't an ASP.NET Core SDK, the SDK components are included with the .NET Core SDK. The value aspnetcore-sdk-2.2 is incorrect and should be dotnet-sdk-2.2. For a list of Linux distributions supported by .NET Core, see .NET Core dependencies and requirements.

Troubleshoot the package manager

This section provides information on common errors you may get while using the package manager to install .NET Core.

Failed to fetch

While installing the .NET Core package, you may see an error similar to signature verification failed for file 'repomd.xml' from repository 'packages-microsoft-com-prod'. Generally speaking, this error means that the package feed for .NET Core is being upgraded with newer package versions, and that you should try again later. During an upgrade, the package feed should not be unavailable for more than 2 hours. If you continually receive this error for more than 2 hours, please file an issue at https://github.com/dotnet/core/issues.