Install .NET (DotNet) on Rocky Linux 8

In this guide, we want to show you to Install .Net (DotNet) Core on Rocky Linux 8.

.NET Core is the latest general-purpose development platform maintained by Microsoft. It works across different platforms and has been redesigned in a way that makes .NET fast, flexible, and modern. This happens to be one of the major contributions of Microsoft. Developers can now build Android, iOS, Linux, Mac, and Windows applications with .NET, all in Open Source.

Steps To Install .NET (DotNet) on Rocky Linux 8

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Rocky Linux 8.

Install .NET (DotNet) on Rocky Linux 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 Rocky Linux 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-7.0

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

sudo dnf install dotnet-sdk-7.0

Check Available Versions of Dotnet

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 Rocky Linux 8 by using the command below:

dotnet --info
Output
.NET SDK:
 Version:   7.0.102
 Commit:    4bbdd14480

Runtime Environment:
 OS Name:     rocky
 OS Version:  8.7
 OS Platform: Linux
 RID:         rocky.8-x64
 Base Path:   /usr/lib64/dotnet/sdk/7.0.102/

Host:
  Version:      7.0.2
  Architecture: x64
  Commit:       d037e070eb

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

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

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

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

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 net7.0
Outout
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /root/MyApp/MyApp.csproj:
  Determining projects to restore...
  Restored /root/MyApp/MyApp.csproj (in 167 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!

Uninstall .Net from Rocky Linux 8

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

sudo dnf remove dotnet

And 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 7.0 then the command will be:

sudo dnf remove dotnet-sdk-7.0

For more information, you can visit the .NET Documentation page.

Conclusion

At this point, you have learned to Install .NET (dotnet) on Rocky Linux 8.

Hope you enjoy it. You may be like these articles on the Orcacore website:

Install and Use Iptables on Rocky Linux 8

Install PostgreSQL 14 on Rocky Linux 8

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!