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

.NET 8.0 brings powerful new features and improvements for developers and production environments alike. Whether you’re building new applications or running them, having the .NET SDK and runtime installed is essential. This guide will take you through the process of installing .NET 8.0 SDK and Runtime on Ubuntu 24.04 LTS.

Step 1: Update Your Package List

Before starting, it’s a good practice to ensure that all your packages are up-to-date. Run the following command to update your system’s package list:

sudo apt update

This ensures that your system is ready to install the latest versions of any required packages.

Step 2: Install Required Dependencies

Install the necessary dependencies that will help with adding the Microsoft repository and ensure smooth installation:

sudo apt install -y apt-transport-https ca-certificates software-properties-common

These packages enable secure communication with the Microsoft repository and proper package management.

Step 3: Add Microsoft Package Signing Key

To install .NET 8.0 from Microsoft’s repository, you need to add their package signing key. This ensures that the packages you download are authentic and trustworthy. Run the following commands to add the key and the package repository:

wget https://packages.microsoft.com/config/ubuntu/24.04/packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb

Once this is done, your system is ready to download and install .NET packages directly from Microsoft.

Step 4: Install the .NET SDK

You can now install the .NET 8.0 SDK, which is needed for developing .NET applications. Use the following command to install it:

sudo apt update
sudo apt install -y dotnet-sdk-8.0

With this, the .NET 8.0 SDK will be installed on your Ubuntu system, allowing you to start developing applications.

Step 5: Install the .NET Runtime (Optional)

If you only need to run .NET applications and don’t plan to develop or compile them, you can opt for just the .NET Runtime:

sudo apt install -y dotnet-runtime-8.0

This is useful for production environments where the development tools are unnecessary.

Step 6: Verify Installation

To ensure the installation was successful, check the installed version of the .NET SDK by running the following command:

dotnet --version

You should see .NET 8.0 in the output, confirming that everything has been installed correctly.

Step 7: Test the Installation by Creating a New .NET Project

Now, let’s test if .NET is properly installed by creating a new .NET console application. Run the following command:

dotnet new console -o my-app
Explanation of the Command:
  • dotnet new console: This command tells the .NET CLI to create a new project of type console. A console application is a simple program that runs in the command line, which is ideal for testing.
  • -o my-app: The -o option stands for “output directory.” It specifies that the new project should be created in a folder called my-app. You can choose any name for your project instead of my-app.

Once the command completes, it will create a new folder called my-app containing all the necessary files for a basic .NET console application.

Step 8: Run the New Application

After creating the project, you can navigate to the project folder and run the application using these commands:

cd my-app

By running cd my-app, you are navigating into the folder where your newly created .NET project files are stored, allowing you to run or edit the project.

dotnet run

dotnet run is a convenient way to quickly compile and execute a .NET application without needing separate build and run steps.

If everything is set up correctly, you should see the output “Hello, World!” in your terminal, which means the .NET SDK is working perfectly.


Conclusion:

By following these steps, you’ve installed .NET 8.0 SDK and Runtime on Ubuntu 24.04 LTS and successfully tested it by creating a new console application. The command dotnet new console -o my-app helps you create a simple project for testing purposes, ensuring your installation was successful.

If you face any challenges during the installation process or want to learn more about .NET, feel free to leave a comment or explore more of our tutorials!


Related Articles:

Java 18 Installation on Ubuntu 22.04 LTS

Reference:

Install .NET SDK or .NET Runtime on Ubuntu official page

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *