How To Install Dotnet Core on Ubuntu 24.04 LTS
.NET Core, now known simply as .NET, is a powerful cross-platform framework for building modern applications. Whether you’re developing web applications, APIs, or microservices, .NET offers robust support for Linux environments like Ubuntu. In this guide, we will walk you through the process of installing .NET Core on Ubuntu 24.04 LTS, the latest long-term support release of the popular Linux distribution.
By the end of this tutorial, you’ll have both the .NET SDK and Runtime installed on your system, enabling you to develop and run .NET applications seamlessly. Let’s dive in!
Prerequisites
Before we begin the installation process, ensure that your system meets the following requirements:
System Requirements
- RAM: Minimum 2GB
- CPU: At least 1 core
- Disk Space: At least 10GB of free space
- Internet Connection: Required for downloading packages and updates
Software Requirements
- Ubuntu 24.04 LTS: Ensure you are running the latest version of Ubuntu.
- Sudo Privileges: You must have administrator (sudo) access to install software.
If you plan to use an integrated development environment (IDE) for coding, we recommend installing Visual Studio Code later in this guide.
Step-by-Step Installation Guide
This section will guide you through installing the .NET SDK and Runtime on your Ubuntu machine.
1. Update System Packages
The first step is to update your system’s package list to ensure you’re working with the latest versions of all software components.
sudo apt update && sudo apt upgrade -y
This command updates your package list and installs any available upgrades for your system packages.
2. Install Required Dependencies
.NET relies on several dependencies to function correctly on Linux systems. These dependencies include tools that allow your system to communicate securely with external repositories.
sudo apt install -y apt-transport-https ca-certificates software-properties-common
This command installs essential packages like apt-transport-https
, which allows your system to download files over HTTPS, and ca-certificates
, which ensures secure communication.
3. Add Microsoft Package Signing Key and Repository
The next step is to add Microsoft’s package signing key to your list of trusted keys so that you can download official .NET packages from their repository.
wget https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
sudo apt update
This command downloads Microsoft’s package configuration file and installs it using dpkg
. Afterward, run an update to refresh your package list with Microsoft’s repository.
4. Install .NET SDK (Software Development Kit)
The .NET SDK includes everything you need to build and run .NET applications locally. In this example, we’ll install version 8.0 of the SDK.
sudo apt install -y dotnet-sdk-8.0
dotnet --version
The first command installs the SDK, while the second verifies the installation by displaying the installed version number (e.g., “8.0.x”). If successful, you’re ready to start developing with .NET!
5. Install .NET Runtime (Optional)
If you only need to run existing applications without developing new ones, you can opt to install just the runtime instead of the full SDK.
sudo apt install -y dotnet-runtime-8.0
dotnet --list-runtimes
This command installs the runtime environment needed to execute pre-built applications and lists all installed runtimes on your machine.
6. Install ASP.NET Core Runtime (Optional)
If you’re working with web applications or APIs built using ASP.NET Core, you’ll need to install the ASP.NET Core Runtime in addition to or instead of the standard runtime.
sudo apt install -y aspnetcore-runtime-8.0
dotnet --list-runtimes
This command installs both the ASP.NET Core runtime and its dependencies for web projects.
7. Verify Installation of All Components
You can verify that both the SDK and runtime are installed correctly by running these commands:
dotnet --list-sdks
dotnet --list-runtimes
The output will display all installed versions of both SDKs and runtimes on your system.
Setting Up Visual Studio Code for .NET Development
If you plan to write code in a lightweight yet powerful IDE, Visual Studio Code is an excellent choice for developing .NET applications on Linux.
1. Installing Visual Studio Code
sudo snap install --classic code
This command installs Visual Studio Code via Snap, ensuring that you always have access to the latest updates automatically.
2. Installing C# Extension in VS Code
The C# extension provides IntelliSense support for C# programming within Visual Studio Code.
- Open Visual Studio Code.
- Press Ctrl + Shift + X or click on “Extensions” in the sidebar menu.
- Search for “C#” by Microsoft and click “Install.”
3. Creating a New .NET Project in VS Code
You can quickly create a new console application using these commands:
dotnet new console -o myApp
cd myApp
dotnet run
This creates a simple “Hello World” application in a folder named “myApp,” navigates into that folder, and runs it using dotnet run
.
Troubleshooting Common Issues
1. Package Not Found Error
If you encounter an error stating that a package cannot be found during installation:
- Ensure that you’ve added Microsoft’s repository correctly by following Step 3 again.
- If necessary, rerun
sudo apt update
.
2. Fixing Dependency Issues
If there are issues with missing or broken dependencies during installation:
sudo apt-get install -f
sudo dpkg --configure -a
Congratulations! You have successfully installed Dotnet Core. Thanks for using this tutorial for installing the Dotnet Core Microsoft on your Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the official Dotnet Core website.