How to Install .NET Core (dotnet) on Ubuntu 22.04
Microsoft .NET Core is a free and open-source software framework. NET Core is the modular and high-performance implementation of .NET for creating web, Windows Mobile, and Windows applications. The Ubuntu 22.04 users can only install .NET Core 6.0. It doesn’t support .NET Core 3.1 or 2.0 since the distro only supports OpenSSL 3.
Useful Article:
- HOW TO INSTALL PHP 8.1/7.4/5.6 ON UBUNTU 22.04/18.04
- HOW TO INSTALL PHP 7.4, 7.3, 7.2 & 7.1 ON UBUNTU 19.10
- HOW TO INSTALL PHP 7.4, 7.3, 7.2, 7.1 ON CENTOS/RHEL 8
- HOW TO INSTALL PHP 7.4, 7.3, 7.2, 7.1 ON CENTOS/RHEL 7/6
- HOW TO INSTALL APACHE TOMCAT 9 ON CENTOS/RHEL 8
- BASIC COMMANDS TO MANAGE WEBSITE/APPPOOL IN IIS
- HOW TO CREATE A WEBSITE/APPPOOL IN IIS USING COMMAND LINE
In this article, I will show you how to install and start with .NET Core on Ubuntu systems.
Step 1: Adding Microsoft Package Repository:
First, enable the Microsoft Apt repository on our Ubuntu systems It does not have .NET Core packages in the official package repository.
$ wget https://packages.microsoft.com/config/ubuntu/22.04/packages-microsoft-prod.deb $ sudo dpkg -i packages-microsoft-prod.deb
Step 2: Installing .NET Core SDK
.Net core SDK package is required If you want to create an application or make changes to an existing application.
We are done with the Microsoft PPA repository, now it’s time to simply use the APT command for the installation of Microsoft dotnet.
$ sudo apt update $ sudo apt install dotnet-sdk-6.0
Step 3: Installing .NET Core Runtime
.NET Core Runtime is required for the system, where you only need to run the application. Use the apt command to install the .NET Core runtime.
$ sudo apt update $ sudo apt install dotnet-sdk-6.0
Step 4: Check the .NET Core Version
Now, to check the .NET Core SDK version, run the following command:
$ dotnet --version
Step 5: Create a Sample Application
Now, we will create a new dotnet sample application on the Ubuntu system. Create a new console application with the command:
$ mkdir Project $ cd Project $ dotnet new console -o Techworld
This will create a .Net core application. To run the application run the below command.
$ cd Project $ dotnet run
You will see the following output.
Enjoy it!