Mono is a platform for cross-platform application development and operation based on ECMA / ISO standards. It is a free and open source application for the Microsoft .NET framework.
This tutorial explains how to install Mono on CentOS 8.
precondition
The instructions assume that you are signed in as a root or superuser sudo
.
Install Mono on CentOS 8
The easiest and recommended way to install Mono on debian 10 is to install it directly from the Mono repository. This is a relatively straightforward process and will only take a few minutes.
- Import the GPG key from the repository with the following command:
sudo rpm --import 'http://pool.sks-keyservers.net/pks/lookup?op=get&search=0x3fa7e0328081bff6a14da29aa6a19b38d3d831ef'
- Add Mono repository to your system by running the command below:
dnf config-manager --add-repo https://download.mono-project.com/repo/centos8-stable.repo
The output will look like this:
Adding repo from: https://download.mono-project.com/repo/centos8-stable.repo
- Once the repository is enabled, install Mono using:
sudo dnf install mono-complete
mono-complete
Are all the metadata packages you need for mono development, mono-complete will install the Mono runtime, development tools and all mono libraries. - Verify the installation by typing the following command that will print the Mono version:
mono --version
At the time of writing this article, the latest stable version of Mono is 6.8.0 fixed (6.8.0.105).
Mono JIT compiler version 6.8.0.105 (tarball Tue Feb 4 19:28:42 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)
At this point, you have successfully installed Mono on CentOS 8, and you can start using it.
Getting started with Mono with Hello World
To verify that everything is set up correctly we will create a program that prints the classic “hello world” message.
Open a text editor nano
And create a file called hello.cs with the following contents:
nano hello.cs
using System; public class HelloWorld { public static void Main(string[] args) { Console.WriteLine ("Hello World!"); } }
use csc
To build the program:
csc hello.cs
The above command will create an executable file named hello.exe
.
Run the executable file using the command below:
mono hello.exe
The output will look like this:
Hello, World
If you want to run the program by typing its name only, you must set a flag so that it can be executed with the chmod command:
chmod +x hello.exe
You can now play the file hello.exe
By typing:
./hello.exe
Conclusion
The latest Mono firmware packages are available for installation from the official Mono package repositories.
.
Originally posted 2020-11-17 12:43:20.