.NET Core
Amazon Linux 2
yum
software installation
cloud computing

Install .NET Core in Amazon Linux 2 using yum

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Installing .NET on Amazon Linux 2 is mostly a matter of adding the Microsoft package repository and then using yum to install the SDK or runtime you need. The main sources of trouble are repository configuration, package naming, and mixing outdated instructions with current package feeds.

Although the article title says .NET Core, modern packages are named simply .NET. The workflow is still the same: configure the repository, install the desired package, and verify that the dotnet command resolves correctly.

Add the Microsoft Package Repository

Start by updating package metadata and installing the helper tools commonly used with yum repositories:

bash
sudo yum update -y
sudo yum install -y yum-utils

Next, add the Microsoft signing key and repository definition for Amazon Linux 2:

bash
sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
sudo curl -o /etc/yum.repos.d/microsoft-prod.repo \
  https://packages.microsoft.com/config/amazonlinux/2/prod.repo

Refresh metadata after the repository file is added:

bash
sudo yum makecache

At this point, yum can see Microsoft packages distributed for Amazon Linux 2.

Install the SDK or Runtime

Choose the package that matches your use case:

  • 'dotnet-sdk-8.0 if you want to build and develop applications'
  • 'aspnetcore-runtime-8.0 if you only need to run ASP.NET Core apps'
  • 'dotnet-runtime-8.0 if you only need the base runtime'

Example SDK installation:

bash
sudo yum install -y dotnet-sdk-8.0

Example runtime-only installation:

bash
sudo yum install -y aspnetcore-runtime-8.0

If your team targets a different supported major version, replace 8.0 with the version your application actually requires. The available versions depend on what the repository currently publishes for Amazon Linux 2.

Verify the Installation

After installation, confirm that the CLI is available and that the expected SDK or runtime was installed:

bash
dotnet --info
dotnet --list-sdks
dotnet --list-runtimes

If you installed only a runtime, dotnet --list-sdks may return nothing, and that is normal. The important part is that the runtime you need appears in dotnet --list-runtimes.

You can also compile a quick test application:

bash
1mkdir hello-dotnet
2cd hello-dotnet
3dotnet new console
4dotnet run

If the output prints Hello, World!, the SDK installation is working correctly.

Understanding Version Choice

One of the most common mistakes is installing whatever package name appears in an old blog post. Amazon Linux 2 environments often live for years, so instructions copied from an earlier release may point to unsupported packages such as old .NET Core 2.x or 3.1 builds.

Use a supported version that matches your application. If you are upgrading an existing service, check the target framework in the project file first:

xml
<TargetFramework>net8.0</TargetFramework>

That value should inform the package you install on the host.

Common Pitfalls

  • Adding the wrong repository file. Amazon Linux 2 should use the Amazon Linux 2 repository path, not a generic RHEL path unless you know exactly why.
  • Installing a runtime when you actually need the SDK. Build commands such as dotnet build and dotnet new require the SDK.
  • Following outdated instructions for unsupported .NET Core versions. Old package names may no longer be available or supported.
  • Forgetting to refresh package metadata after adding the repository.
  • Mixing packages from multiple sources in an ad hoc way. Keep the host on a clear, intentional package source strategy.

Summary

  • Add the Microsoft package repository for Amazon Linux 2 before installing .NET packages.
  • Use dotnet-sdk-8.0 for development and a runtime package for execution-only hosts.
  • Verify installation with dotnet --info, dotnet --list-sdks, and dotnet --list-runtimes.
  • Match the installed package version to the application's target framework.
  • Most installation failures come from outdated instructions or incorrect repository setup.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.