YouTube Icon

Code Playground.

How to Install Mono on Ubuntu 20.04

CFG

How to Install Mono on Ubuntu 20.04

Mono is a stage for creating and running cross-stage applications dependent on the ECMA/ISO Standards. It is a free and open-source execution of Microsoft's .NET system. 

This instructional exercise covers the means needed to introduce Mono on Ubuntu 20.04. 

Prerequisites

The guidelines expect that you are signed in as root or client with sudo benefits . 

Installing Mono on Ubuntu

Mono isn't accessible in the standard Ubuntu 20.04 vaults. We'll introduce the Mono bundles from the official

sudo apt update
sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common

Mono's archives: 

Introduce the conditions important to include another storehouse over HTTPS: 

Import the storehouse's GPG key: 

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF

The yield should look something like this: 

gpg: key A6A19B38D3D831EF: public key "Xamarin Public Jenkins (auto-signing) <releng@xamarin.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Add the Mono vault to your framework sources' rundown: 

sudo apt-add-repository 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main'

Install Mono:

sudo apt install mono-complete 

mono-complete is a meta-bundle that introduces the Mono runtime, improvement instruments, and all libraries. 

The establishment may take a couple of moments to finish. When finished, confirm it by composing the accompanying order which will print the Mono adaptation: 

mono --version

At the hour of composing this article, the most recent stable form of Mono is 6.8.0.123. 

Mono JIT compiler rendition 6.8.0.123 (tarball Tue May 12 15:11:57 UTC 2020) 

Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com 

Mono JIT compiler version 6.8.0.123 (tarball Tue May 12 15:11:57 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)

That is it, Mono has been introduced on your Ubuntu machine, and you can begin utilizing it. 

Getting Started with Mono

To guarantee that everything is set up effectively, we will construct a Hello World program that prints the exemplary "hi world" message. 

Open your word processor and make a record named hello.cs with the accompanying substance: 

hello.cs

using System;

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

Utilize the csc compiler to construct the program: 

csc hello.cs

The order above will make an executable named hello.exe. 

Run the executable: 

mono hello.exe

The yield should look something like this: 

Hello, World

To execute the program just by composing its name, set an executable banner : 

 


chmod +x hello.exe

You would now be able to run the hello.exe record by composing: 

./hello.exe

Conclusion

Introducing Mono on Ubuntu 20.04 is a moderately clear cycle, and it will take you just a couple of moments. 

On the off chance that you hit an issue or have input, leave a remark underneath.




CFG