How to compile a Visual Studio C# Project with Mono

I'm new to this, and don't know where to start.

I want to compile a Visual Studio C# project with Mono on Linux (by command line).

The main.cs file includes these references:

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Imaging;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Xml;
using iTextSharp.text;
using iTextSharp.text.pdf;

I have no idea whether I need to note the references to the compiler, or whether it will pull them in itself, whether it will know where to look for them or not. I've never done this before. But I just need to compile this project.

Thank you!


Have you tried xbuild? It's the MSBuild equivalent on the Mono world. If MSBuild is able to compile your project in Windows, xbuild should be able to do the same on Linux (if it doesn't, file a bug in Bugzilla).

UPDATE: Nowadays, Mono developers/packagers are in the process of bundling the original (and recently opensourced) MSBuild, which is now crossplatform. For example it's already available in the latest Mono installers for Mac, so you can use the command-line program msbuild to build your project/solutions (note: still a long way to go to be bundled by Linux distros because msbuild depends on nuget packages, aka binary blobs).


knocte is right, install mono-complete

apt-get install mono-complete

I don't know why but I had errors compling with only mono-xbuild installed,

and run from the command line :

xbuild yourvisualcsharpproject.csproj

You can build in visual studio and deploy on Linux and run under mono.Have a look on this article