How to install Monodevelop in 20.04 and get it to build something?

I am trying to setup a development machine using 20.04 and am having problems with the Monodevelop environment.

Whenever I create a solution and project it seems that it cannot find the proper build setup. I suspect there is some problem when using the 18.04 mono repositories on 20.04, but I can't find out how to fix it.

This is the error I receive when I try to build using the Monodevelop IDE:

/usr/lib/mono/msbuild/15.0/bin/Microsoft.CSharp.CurrentVersion.targets(5,5): 
Error MSB4019: The imported project "/usr/lib/mono/msbuild/15.0/bin/Roslyn/Microsoft.CSharp.Core.targets" was not found.
Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. (MSB4019) (HelloWorld)

Does anyone know how to get a working version of Monodevelop on Ubuntu 20.04?


I managed to fix this on Ubuntu 20.04.

First, add mono-project's repo for 18.04 by following the official instructions, pasted here for convenience:

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu stable-bionic main" | sudo tee /etc/apt/sources.list.d/mono-official-stable.list
sudo apt update

Then install mono-roslyn using:

sudo apt install mono-roslyn

Rebuild your project.


Mono is not yet available in stable repo, but you can install it with the preview-focal main with the following.

sudo apt install gnupg ca-certificates
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb https://download.mono-project.com/repo/ubuntu preview-focal main" | sudo tee /etc/apt/sources.list.d/mono-official-preview.list
sudo apt update

# if the packages were already installed
sudo apt upgrade

# otherwise
sudo apt install mono-complete msbuild

Later you can test it with a simple hello world application by creating a file called hello.cs

using System;

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

Compile it with csc hello.cs. It will generate an exe. Now run it with mono hello.exe and it should work