How to install Dotnet in AlmaLinux 8

Learn the commands to install .Net Framework and runtime on AlmaLinux 8 using terminal and DNF package manager.

.NET is a free, cross-platform, open-source developer platform from Microsoft that can be used to create and run programs for Windows. The software is pronounced “dot-net framework”. Programmers can use .NET to develop and test their own software for Windows computers. Several programming languages ​​such as C# or C++ are supported so that as many programmers as possible can use the program to build for web, mobile, desktop, games, and IoT.

If you install a program that was created with .NET, you also need the .NET Framework. This ensures that all functions of the software work correctly on your computer.

Well, installation of Dotnet is pretty easy on Windows, however, being open-source and cross-platform it can also be installed on Linux for the development of .Net-based applications.

Steps to install .NET Runtime & SDK on Almalinux 8

The steps given here will be the same for other RedHat-based Linux operating systems such as Oracle Linux, CentOS, Rocky Linux, and others…

#1st method using Dnf Package manager

1. Run Update command

As we are going to use the DNF package manager and official repositories of Almalinux 8, hence, first run the system update command:

sudo dnf update --refresh

 

2. Install Dotnet on Almalinux 8

The packages we need to configure Dotnet on Almalinux are available to install using its official App stream and base repositories. Hence, follow the given commands to install runtime and SDK.

For both .Net tools, runtime, and SDK:

sudo dnf install dotnet

For only .Net Runtime:

sudo dnf install dotnet-runtime-6.0

For NET Software Development Kit

The latest version while doing this article of .Net SDK was 6.0, hence to install use:

sudo dnf install dotnet-sdk-6.0

Note: For other versions, just need to change the 6.0 with that. You can check what are the available versions to install by using a command:

sudo dnf search dotnet

 

3. Check the Version

Once the installation is completed, we can check the version of installed Dotnet by using its command-line tool, here is that.

dotnet --info

OutPut:

.NET SDK (reflecting any global.json):
Version: 6.0.103
Commit: 2c677ffc1e

Runtime Environment:
OS Name: Almalinui
OS Version: 8.5
OS Platform: Linux
RID: rhel.8-x64
Base Path: /usr/lib64/dotnet/sdk/6.0.103/

Host (useful for support):
Version: 6.0.3
Commit: c24d9a9c91

.NET SDKs installed:
6.0.103 [/usr/lib64/dotnet/sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.3 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.3 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

 

4. Create your first App

Let’s create a new console app using the command:

dotnet new console -o MyApp -f net6.0

In the above command, MyApp is the project directory’s name that we are using to store all required files to develop an application, whereas net6.0 is the version of Dotnet we are using to create an app.

Switch to create a directory:

cd Myapp

Create your first App using Dotnet on Almalinux

Now, there is already a demo program inside the created project directory called program.cs, to run it use the command:

dotnet run

You will see output- “hello-world”

dotnet run app

 

5. How to uninstall

To remove Dotnet in the future if you don’t require it, use the DNF again:

sudo dnf remove dotnet

Whereas for some particular SDK or runtime version

sudo dnf remove dotnet-sdk-your-version
sudo dnf remove dotnet-runtime-your-version

For example, if the version is 6.0 then the command will be:

sudo dnf remove dotnet-sdk-6.0

For more information refer to the official documentation. 

 

Other Articles:

How to install Lighttpd on AlmaLinux 8
How to install Skype on Almalinux 8
Install PrestaShop on Almalinux 8
Command to Permanently Disable SELinux on AlmaLinux 

 

 

 

Leave a Comment

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