Install .NET SDK and .NET Runtime on Ubuntu 24.04 LTS

In this article we are going to cover Install .NET SDK and .NET Runtime on Ubuntu 24.04 LTS.

In 2016, Microsoft released .NET Core (what is now simply called .NET) as a completely new implementation of the platform. .NET applications can be distributed as either self-contained or framework-dependent executables. Self-contained applications already include the necessary .NET runtime files and libraries needed to run the application.

Prerequisites:

  • Ubuntu 24.04 LTS with minimum 2GB RAM and 1 CPU.
  • SSH access with sudo privileges

Step#1:Download and Install .NET SDK and .NET Runtime on Ubuntu

Let’s start the hands-on lab to install .NET SDk and .NET Runtime on ubuntu 24.04 LTS

Update the system packages on Ubuntu 24.04 LTS

sudo apt update

Install .NET SDK (Software Development Kit) to build and run.NET applications.

sudo apt install -y dotnet-sdk-8.0

Output:

ubuntu@ip-172-31-0-129:~$ sudo apt install -y dotnet-sdk-8.0
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
The following additional packages will be installed:
  aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host-8.0 dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-targeting-pack-8.0 dotnet-templates-8.0
  liblttng-ust-common1t64 liblttng-ust-ctl5t64 liblttng-ust1t64 netstandard-targeting-pack-2.1-8.0
The following NEW packages will be installed:
  aspnetcore-runtime-8.0 aspnetcore-targeting-pack-8.0 dotnet-apphost-pack-8.0 dotnet-host-8.0 dotnet-hostfxr-8.0 dotnet-runtime-8.0 dotnet-sdk-8.0 dotnet-targeting-pack-8.0
  dotnet-templates-8.0 liblttng-ust-common1t64 liblttng-ust-ctl5t64 liblttng-ust1t64 netstandard-targeting-pack-2.1-8.0
0 upgraded, 13 newly installed, 0 to remove and 42 not upgraded.
Need to get 136 MB/136 MB of archives.
After this operation, 496 MB of additional disk space will be used.
Get:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 dotnet-host-8.0 amd64 8.0.7-0ubuntu1~24.04.1 [185 kB]
Get:2 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 dotnet-hostfxr-8.0 amd64 8.0.7-0ubuntu1~24.04.1 [144 kB]
Get:3 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 dotnet-runtime-8.0 amd64 8.0.7-0ubuntu1~24.04.1 [23.9 MB]
Get:4 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 aspnetcore-runtime-8.0 amd64 8.0.7-0ubuntu1~24.04.1 [8314 kB]
Get:5 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 aspnetcore-targeting-pack-8.0 amd64 8.0.7-0ubuntu1~24.04.1 [1912 kB]
Get:6 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 dotnet-apphost-pack-8.0 amd64 8.0.7-0ubuntu1~24.04.1 [3883 kB]
Get:7 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 dotnet-targeting-pack-8.0 amd64 8.0.7-0ubuntu1~24.04.1 [2950 kB]
Get:8 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 dotnet-templates-8.0 amd64 8.0.107-0ubuntu1~24.04.1 [2196 kB]
Get:9 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 netstandard-targeting-pack-2.1-8.0 amd64 8.0.107-0ubuntu1~24.04.1 [1391 kB]
Get:10 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble-updates/main amd64 dotnet-sdk-8.0 amd64 8.0.107-0ubuntu1~24.04.1 [90.9 MB]
Fetched 136 MB in 3s (41.3 MB/s)
Selecting previously unselected package dotnet-host-8.0.

Additionally, you may also need to install the .NET Runtime if you’re running applications that were built with .NET but don’t include the runtime.

sudo apt install -y aspnetcore-runtime-8.0

Install the ASP.NET Core Runtime, which is the most compatible runtime for .NET 8.0. Alternatively, you can install the .NET Runtime without the ASP.NET Core components by using the following command.

sudo apt install -y dotnet-runtime-8.0

Verify the installation by running the below command

dotnet --version

Output:

ubuntu@ip-172-31-0-129:~$ dotnet --version
8.0.107

You can try creating a new .NET project to ensure that the installation was successful.

dotnet new console -o my-app
cd my-app
dotnet run

Output:

ubuntu@ip-172-31-0-129:~$ dotnet new console -o my-app

Welcome to .NET 8.0!
---------------------
SDK Version: 8.0.107

----------------
Installed an ASP.NET Core HTTPS development certificate.
To trust the certificate, view the instructions: https://aka.ms/dotnet-https-linux

----------------
Write your first app: https://aka.ms/dotnet-hello-world
Find out what's new: https://aka.ms/dotnet-whats-new
Explore documentation: https://aka.ms/dotnet-docs
Report issues and find source on GitHub: https://github.com/dotnet/core
Use 'dotnet --help' to see available commands or visit: https://aka.ms/dotnet-cli
--------------------------------------------------------------------------------------
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /home/ubuntu/my-app/my-app.csproj:
  Determining projects to restore...
  Restored /home/ubuntu/my-app/my-app.csproj (in 715 ms).
Restore succeeded.
ubuntu@ip-172-31-0-129:~$ cd my-app
dotnet run
Hello, World!

This will create a new .NET Console application, navigate to the project directory, and run the application. If everything is set up correctly, you should see the default “Hello, World!” output in the terminal.

Step#2:Install Visual Studio Code on Ubuntu 24.04 LTS

sudo apt install software-properties-common apt-transport-https wget -y
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
sudo apt install code
code --version

Output:

ubuntu@ip-172-31-0-129:~$ sudo apt install software-properties-common apt-transport-https wget -y
wget -q https://packages.microsoft.com/keys/microsoft.asc -O- | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main"
sudo apt update
sudo apt install code
code --version
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
software-properties-common is already the newest version (0.99.48).
software-properties-common set to manually installed.
wget is already the newest version (1.21.4-1ubuntu4.1).
wget set to manually installed.
The following NEW packages will be installed:
  apt-transport-https
0 upgraded, 1 newly installed, 0 to remove and 42 not upgraded.
Need to get 3974 B of archives.
After this operation, 35.8 kB of additional disk space will be used.
Get:1 http://ap-south-1.ec2.archive.ubuntu.com/ubuntu noble/universe amd64 apt-transport-https all 2.7.14build2 [3974 B]
Fetched 3974 B in 0s (280 kB/s)
Selecting previously unselected package apt-transport-https.
(Reading database ... 72448 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_2.7.14build2_all.deb ...
Unpacking apt-transport-https (2.7.14build2) ...
Setting up apt-transport-https (2.7.14build2) ...
Scanning processes...
Scanning linux images...

Running kernel seems to be up-to-date.

No services need to be restarted.

No containers need to be restarted.

No user sessions are running outdated binaries.

Open VS Code, go to the Extensions view (Ctrl+Shift+X), and search for “C#” and install the extension provided by Microsoft.

Install .NET SDK and .NET Runtime on Ubuntu 24.04 LTS 1

Now, start developing .NET applications on your Ubuntu system. Create a new project or open an existing one using the dotnet new and dotnet build commands in your terminal.

Here, we you have wrapped up, how to Install .NET SDK and .NET Runtime on Ubuntu 24.04 LTS

Related Articles:

How to Install DotNet Core SDK on Ubuntu 18.04 LTS

Ankita Lunawat

Working as DevOps Intern likes to share Knowledge.

2 thoughts on “Install .NET SDK and .NET Runtime on Ubuntu 24.04 LTS”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Share via
Copy link
Powered by Social Snap