Saturday, September 24, 2022

How To Set up Mono Software on AlmaLinux 8

In this article, we want to teach you How To Set up Mono Software on AlmaLinux 8.

Mono is a software platform designed to allow developers to easily create cross-platform applications part of the .NET Foundation.

I is an open-source implementation of Microsoft’s.NET Framework based on the ECMA standards for C# and the Common Language Runtime.

Set up Mono Software on AlmaLinux 8

You need to log in to your server as a non-root user with sudo privileges. To do this, you can check the Initial Server Setup article for AlmaLinux 8.

To install Mono software on AlmaLinux 8 follow the steps below.

Update your local package index with the following command:

sudo dnf update

Now import the repository’s GPG key with the command below:

sudo rpmkeys --import "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF"

On success, no output is produced.

Here you need to add the Mono repository on AlmaLinux 8:

dnf config-manager --add-repo https://download.mono-project.com/repo/centos8-stable.repo

In your output you will see:

Output
Adding repo from: https://download.mono-project.com/repo/centos8-stable.repo

At this point, you can install Mono Software on AlmaLinux 8 with the following command:

sudo dnf install mono-complete

Verify your installation with the Mono version:

mono --version

In your output you will see:

Output
Mono JIT compiler version 6.12.0.107 (tarball Wed Dec 9 21:44:58 UTC 2020)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com
TLS: __thread
SIGSEGV: altstack
Notifications: epoll
Architecture: amd64
Disabled: none
Misc: softdebug
Interpreter: yes
LLVM: yes(610)
Suspend: hybrid
GC: sgen (concurrent by default)

You have now successfully set up Mono on AlmaLinux 8.

Let’s start using it.

How To Use Mono Software

To make sure that Mono is set up correctly on your server, you can build a Hello World program that prints the classic “hello world” message.

You need to create a file named hello.cs with your favorite text editor, here we use vi:

sudo vi hello.cs

Paste the following content to the file:

using System;

public class HelloWorld
{
   public static void Main(string[] args)
   {
        Console.WriteLine ("Hello World!");
   }
}

When you are done, save and close the file.

Now you can use the CSC compiler to build the program:

csc hello.cs

This command will create an executable program named hello.exe.

Now run the program with Mono on AlmaLinux 8:

mono hello.exe

In your output you will see:

Output
Hello World!

If you want to execute the program only by typing its name, you’ll need to set an executable flag. To do this, you can use the following command:

chmod +x hello.exe

Now you can run the hello.exe file with the following command:

./hello.exe

Conclusion

At this point, you learn to Install Mono on AlmaLinux 8. Also, you learn to use it by printing the hello world message.

Hope you enjoy it.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles

POPULAR TAGS

Most Popular