How To Install and Use Dotnet on AlmaLinux 8

In this article, we want to teach you How To Install and Use Dotnet on AlmaLinux 8.

What is Dotnet (.NET)?

Formally, .NET is “an open-source developer platform, created by Microsoft, for building many different types of applications. You can write .NET apps in C#, F#, Visual C++, or Visual Basic.”

Informally, .NET is the tool that lets you build and run C# programs (we’ll avoid F#, Visual C++, Visual Basic for now).

When you download .NET, you’re really downloading a bunch of programs that:

  • Translate your C# code into instructions that a computer can understand
  • Provide utilities for building software, like tools for printing text to the screen and finding the current time
  • Define a set of data types that make it easier for you to store information in your programs, like text, numbers, and dates

There are a few versions of .NET. They do the same job but they are meant for different operating systems:

  • The “.NET Framework” is the original version of “dot net” that only runs on Windows computers.
  • “.NET Core” is the new, cross-platform version of “dot net” that runs on Windows, macOS, and Linux computers.

Whenever we refer to “.NET” from now on, we really mean .NET Core.

How To Install and Use Dotnet (.NET) on AlmaLinux 8

Before you start to install .NET on AlmaLinux 8, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with AlmaLinux 8.

Now follow the steps below to complete this guide.

Install .NET (dot net) on AlmaLinux 8

First, you need to update your local package index with the following command:

sudo dnf update -y

.NET packages are available in the default AlmaLinux repository.

You can install .Net tools, runtime, and SDK with the following command:

sudo dnf install dotnet

For installing only .NET Runtime, you can use the following command:

sudo dnf install dotnet-runtime-6.0

If you want to install the Net Software Development Kit (.Net SDK), you can use the command below:

sudo dnf install dotnet-sdk-6.0

Note: You can check what are the available versions to install with the command below:

sudo dnf search dotnet

When your installation is completed, you can verify your Dotnet (.NET) installation on AlmaLinux 8 by using the command below:

dotnet --info
Output
.NET SDK (reflecting any global.json):
Version: 6.0.104
Commit: 915d644e45

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

Host (useful for support):
Version: 6.0.4
Commit: be98e88c76

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

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

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

Now let’s see how to use the Dotnet (.NET) by creating a sample project on AlmaLinux 8.

Create a Sample Project with the .NET

First, you need to create a new console app with the following command, here we named it MyApp:

dotnet new console -o MyApp -f net6.0
Outout
The template "Console App" was created successfully.

Processing post-creation actions...
Running 'dotnet restore' on /root/MyApp/MyApp.csproj...
Determining projects to restore...
Restored /root/MyApp/MyApp.csproj (in 168 ms).
Restore succeeded.

Then, switch to your project directory:

cd MyApp

There is already a demo program inside the created project directory called program.cs. To run the demo program, use the following command:

dotnet run
Output
Hello, World!

How To Remove .Net from AlmaLinux 8

If you don’t want to use “.NET” anymore, you can easily remove it with the command below:

sudo dnf remove dotnet

For the SDK and runtime, you can use the following commands:

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

Conclusion

At this point, you learn to Install and Use Dotnet on AlmaLinux 8.

Hope you enjoy this guide on the orcacore website.

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

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

Stay informed and not overwhelmed, subscribe now!