Oct 12, 2023 5 min read

How to Install Mono Framework on Debian 10

Install Mono Framework on Debian 10 with our step-by-step tutorial. It is an open-source implementation of Microsoft's .NET Framework.

Install Mono Framework on Debian 10
Table of Contents

Choose a different version or distribution

Introduction

Before we begin talking about how to install Mono Framework on Debian 10, let's briefly understand – What is Mono?

Mono Framework is an open-source implementation of Microsoft's .NET Framework. It enables developers to create and run cross-platform applications on Linux, macOS, and Windows operating systems.

Mono allows developers to write applications in various programming languages, including C#, Visual Basic, and F#. Mono lets you easily integrate .NET technologies into your applications and is widely used by developers worldwide.

It is a powerful tool for creating applications that are compatible with multiple operating systems and can help developers save time and reduce development costs.

In this tutorial, you will install Mono Framework on Debian 10. We will also address a few FAQs on how to install Mono Framework on Debian 10.

Advantages of Mono Framework

  1. Cross-platform compatibility: Mono Framework enables developers to build and run applications on various operating systems, including Linux, Windows, and macOS.
  2. Language interoperability: Mono Framework allows developers to write applications in multiple programming languages such as C#, VB.NET, and F#.
  3. High-performance: Mono Framework provides fast execution and runtime performance through just-in-time (JIT) compilation and garbage collection.
  4. Large Developer Community: Mono Framework has a large user and developer community that regularly contributes plugins, libraries, and tools.
  5. Excellent Development Tools: Mono Framework is designed with excellent development tools like IDEs such as Visual Studio and Xamarin Studio, which allow developers to develop applications quickly and efficiently.

Prerequisites

Before we begin:

  • It is advised that you use Debian 11 OS.
  • Make sure to login as a user account with sudo privileges or root access su command.

Updating Operating System

Make sure all existing packages are up-to-date by updating your Debian 10 operating system:

sudo apt update && sudo apt upgrade -y

Root or Sudo Access

Unlike other distributions, Debian does not immediately assign your account the sudoers status when you create it at startup. To use the su command, you must either know the root password or visit the lesson on How to Add a User to Sudoers on Debian.

Install Required Dependencies

To successfully install and use Mono on your Debian 10 system, you will need the following dependencies. Run the following command to install them and verify that they are installed by opening your command prompt.

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

Import Mono GPG Key & Repository

Since Mono is not included in Debian 10s repository, the first step in the installation will be to import the GPG key and repository.

Import the GPG key first:

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

Import the Mono repository next.

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

Keep in mind that this is the Buster repository. It does, however, work for Debian 10.

Update your repository list to reflect the changes now that the Mono repository and GPG key have been added.

sudo apt update

Install Mono Framework

It is time to install Mono now that the repository has been installed properly. You will use the below apt install command to accomplish this.

sudo apt install mono-complete -y

Check the installation and the installed version next.

mono --version

Example output:

Output

Mono JIT compiler version 6.8.0.105 (Debian 6.8.0.105+dfsg-3.2 Wed Dec 14 21:01:01 UTC 2022)

Alternatively, you can use the apt-cache policy command to confirm the Mono Framework installation.

sudo apt-cache policy mono-complete

Example output:

Output

mono-complete:
  Installed: 6.8.0.105+dfsg-3.2
  Candidate: 6.8.0.105+dfsg-3.2
  Version table:
 *** 6.8.0.105+dfsg-3.2 500
        500 http://ftp.au.debian.org/debian bullseye/main amd64 Packages
        100 /var/lib/dpkg/status

Create a Test Application

You will create a short program with a well-known catchphrase in order to verify that Mono is functioning (Hello World). You will accomplish this by launching your preferred text editor. The nano text editor will be used in this guide.

Open your terminal and generate a .cs file as shown below.

sudo nano helloworld.cs

After that, enter the programming code that follows:

using System;

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

Once finished, press CTRL+O to save and CTRL+X to exit.

The code is now ready for compilation. Execute the following command to do this:

mono-csc helloworld.cs

The compiler command will generate an executable called helloworld.exe, which you can execute to see the code in action by issuing the following command:

mono helloworld.exe

You will now see the classic output:

Output

Hello World!

Making the file executable on its own is another approach for executing the program. To accomplish this, modify the file's permissions as shown below:

chmod +x helloworld.exe

By using the next command, you can now run the file independently:

./helloworld.exe

The output for Hello World should appear once more. You might need to set the $PATH variable if you encounter any issues.

export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"

FAQs to Install Mono Framework on Debian 10

How do I check if Mono Framework is installed on my Debian 10?

Open the terminal and type in the command mono --version. If Mono is installed, the version number will be displayed.

What is the difference between mono-complete and mono-runtime packages?

The mono-complete package contains both the Mono runtime and development tools, while the mono-runtime contains only the runtime

How do I update Mono Framework to the latest version on Debian 10?

Open the terminal and type in the command sudo apt-get update && sudo apt-get upgrade mono-complete.

How do I uninstall Mono Framework from my Debian 10 system?

Open the terminal and type in the command sudo apt-get remove mono-complete.

Can I install specific versions of Mono Framework on Debian 10?

Yes, you can. You can use apt-get install mono-complete=VERSION_NUMBER to install a specific version of Mono.

How do I install Mono Framework on Debian 10 without an internet connection?

You can download the mono-complete .deb package from Debian's website and install it using the dpkg command.

What are some common issues I may face while installing Mono Framework on Debian 10?

Some common issues include missing dependencies and conflicts with other packages. You can try resolving them by running sudo apt-get -f install.

How do I confirm that Mono Framework is properly installed on my Debian 10 system?

You can create a simple "Hello World" C# program and compile it with mcs command. Then, you can execute the program using mono PROGRAM_NAME.exe command. If it executes without errors and outputs "Hello World", then Mono Framework is properly installed.

Conclusion

In this tutorial, you installed the Mono framework and executed your first program on your Debian 10. Overall, Mono is a great alternative for developers because it is cross-platform, free of vendor lock-ins and software license fees, and open-source. The only drawback to Mono is that occasionally when a new version of the .NET framework is released, its API may not be as readily up to date.

Visit the official documentation to learn more about using Mono.

If you have any queries, please leave a comment below, and we’ll be happy to respond to them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Blog - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.