Article Directory
This article was first published in: https://www.itcoder.tech/posts/how-to-install-mono-on-ubuntu-20-04/
Mono is a platform based on ECMA/ISO standards for developing and running cross-platform applications. It is a free and open source implementation of Microsoft's .NET framework.
This article mainly concerns how to install Mono on Ubuntu 20.04.
The following instructions assume that you are logged into the system as root or other sudo privileges.
Mono is not available in the standard Ubuntu software source repositories. We will install Mono from the official Mono source repository. This is a very simple and straightforward process that only takes a few minutes.
sudo apt update
sudo apt install dirmngr gnupg apt-transport-https ca-certificates software-properties-common
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80--recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
The output should look like this:
gpg: key A6A19B38D3D831EF:public key "Xamarin Public Jenkins (auto-signing) <[email protected]>" imported
gpg: Total number processed:1
gpg: imported:1
sudo apt-add-repository 'deb https://download.mono-project.com/repo/ubuntu stable-bionic main'
sudo apt install mono-complete
Mono-complete
is a meta-package, it will install all the packages you need for Mono development, including the runtime environment, development tools and all class libraries.
mono --version
At the time of writing, the latest stable version of Mono is 6.8.0.123.
Mono JIT compiler version 6.8.0.123(tarball Tue May 1215: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's it, you have successfully installed Mono on your Ubuntu machine, and you can start using it.
To verify that all settings are normal, we will build a Hello World program, which will print the "hello world" message.
Open your text editor and create a file named hello.cs
with the following content:
using System;publicclassHelloWorld{publicstaticvoidMain(string[] args){
Console.WriteLine("Hello World!");}}
Use the csc
compiler to build the program:
csc hello.cs
The above command will build an executable program named: hello.exe
.
Run this executable program:
mono hello.exe
The output will look like this:
Hello, World
To run the program by entering the program name, you need to make the file executable:
chmod +x hello.exe
Now you can run hello.exe
and type:
. /hello.exe
Installing Mono on Ubuntu 20.04 is a relatively straightforward process, and it will only take you a little time.
If you have any questions, please contact us in the following ways:
WeChat:
WeChat group: add the above WeChat, remark the WeChat group
QQ: 3217680847
QQ Group: 82695646
Recommended Posts