Mono is a free, open-source development platform based on the .NET Framework. Mono’s .NET implementation is based on the ECMA/ISO standards for C# and the Common Language Infrastructure.
At the end of the guide, you will know how to install and configure Mono on your Debian 10 Buster operating system.
- Recommended OS: Debian 10 Buster
- User account: A user account with sudo or root access.
- Required packages: dirmngr, gnupg, apt-transport-https, ca-certificates
Before you begin, make sure your Debian 10 system is up to date:
sudo apt update && sudo apt upgrade -y
Next, install the following required packages:
sudo apt install dirmngr gnupg apt-transport-https ca-certificates -y
Install Mono on Debian 10
To add the official repository to install Mono and update the software in future, you need to add the GPG key:
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
You will see an output as per below:
Now you can proceed to add the official repository to your Debian system by executing the following code:
sudo sh -c 'echo "deb https://download.mono-project.com/repo/debian stable-buster main" > /etc/apt/sources.list.d/mono-official-stable.list'
Now that you have added the repository, you can now update your source list and install the software using the apt package manager by executing the following code in your terminal:
sudo apt update && sudo apt install mono-complete -y
The installation does take about 3 to 5 minutes, as it does some compiling during the install. Once complete, the (complete) package installs all the tools you need for Mono, including libraries, runtime and other various tools.
Lastly, verify the version you have installed by typing the following command:
Note, the version at the time of writing this guide is (220.127.116.11) and will likely change by installing Mono yourself.
How to use Mono – Example Program
To check that Mono is working, you will create a small program with the famous catchphrase (Hello World). You will do this by opening your favourite text editor to accomplish this. For the guide, we will use the nano text editor.
Open your terminal (CTRL+ALT+T) and execute the following command:
sudo nano helloworld.cs
Next, enter the following programming code:
public class HelloWorld
public static void Main(string args)
Console.WriteLine ("Hello World!");
Once done, (CTRL+O) to save, then (CTRL+X) to exit.
Now you can compile the code. To do this, execute the following command:
The compiler command will build an executable named helloworld.exe, once complete you can run this to see the code in action by executing the following command:
You will then get the classic output:
An alternative way to execute the program is by making the file executable by itself. This can be done by changing the permissions of the file as below:
chmod +x helloworld.exe
Now you can run the file on its own by executing the following command:
Comments and Conclusion:
In the guide, you have learnt to install Mono and execute your first small program on your Debian 10 Operating system. Overall, Mono is a terrific option for developers that is cross-platform with not having to pay for software licenses or vendor lock-ins along with being open-source. The only downside to Mono is that sometimes its API can be not as up to date immediately when a new version of the .NET framework is released.
For more information on using Mono, visit the official documentation.