YouTube Icon

Code Playground.

How to Install Mono on Ubuntu 18.04

CFG

How to Install Mono on Ubuntu 18.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 usage of Microsoft's .NET system. 

This instructional exercise discloses how to introduce Mono on Ubuntu 18.04. 

Prerequisites

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

Installing Mono on Ubuntu

The most effortless and the prescribed method to introduce Mono on Ubuntu 18.04 is to introduce it from Mono's archives. It is a moderately direct cycle and will just take a couple of moments. 

Start by introducing the important bundles: 

sudo apt update
sudo apt install dirmngr gnupg apt-transport-https ca-certificates

Import the vault's GPG key utilizing the accompanying order: 

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 store to your framework sources' rundown by running the order beneath: 

sudo sh -c 'echo "deb https://download.mono-project.com/repo/ubuntu stable-focal main" > /etc/apt/sources.list.d/mono-official-stable.list'

When the adept vault is empowered , update the bundles list and introduce Mono with: 

sudo apt update
sudo apt install mono-complete 

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

Check the establishment by composing the accompanying order which will print the Mono variant: 

mono --version

At the hour of composing this article, the most recent stable form of Mono is 6.6.0 Stable (6.6.0.161). 

Mono JIT compiler version 6.6.0.161 (tarball Tue Dec 10 10:36:32 UTC 2019)
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, you have effectively introduced Mono on your Ubuntu, and you can begin utilizing it. 

Getting Started with Mono

To confirm that everything is set up effectively, we'll construct a Hello World program that will print the exemplary "hi world" message. 

Open your word processor and make a document 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 fabricate an executable named hello.exe. 

Run the executable utilizing the order beneath: 

mono hello.exe

The yield should look something like this: 

Hello, World

On the off chance that you need to execute the program just by composing its name, you'll have to set an executable banner : 

chmod +x hello.exe

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

./hello.exe

Conclusion

The most recent stable Mono delivery bundles are accessible for establishment from the official Mono bundle archive. 

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




CFG