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

12,163

Solution 1

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.

Solution 2

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

Share:
12,163

Related videos on Youtube

sysrpl
Author by

sysrpl

Updated on September 18, 2022

Comments

  • sysrpl
    sysrpl over 1 year

    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?

    • N0rbert
      N0rbert about 4 years
      For close voters - 20.04 LTS is released. About MonoDevelop see askubuntu.com/a/1228572/66509 .
    • Peter Gloor
      Peter Gloor about 4 years
      I'm not using MonoDevelop, but compile projects that have been created in Visual Studio. Since Mono version 5.n I've been using msbuild to compile my projects, but this no longer works in Ubuntu 20.04. In my case, msbuild cannot be found. Trying to install msbuild doesn't fix the issue.
  • geekley
    geekley over 3 years
    It's worth mentioning this explicitly: As of now, the Ubuntu 20.04 repo version of mono-complete 6.8 doesn't include msbuild, mono-roslyn, etc (maybe because of license?) so adding the mono repo to apt really is necessary if you want to use msbuild instead of the deprecated xbuild.
  • Andreas Fester
    Andreas Fester over 3 years
    This also worked for me on Ubuntu 20.10 (which also still has mono 6.8 by default)