How can you use Mono's mcs to compile and run a csproj file?

40.6k Views Asked by At

I'm a Unix guy who needs to try and compile some C# code for work. I've downloaded Mono for Mac, and the mcs command line tool. There's a csproj file attached to this library which contains XML with all of the files I need to compile.

Can Mono/mcs read this csproj file and generate a DLL from it?

3

There are 3 best solutions below

4
On

If you don't want to use MonoDevelop and want to use the command-line, you can use xbuild. xbuild is the Mono equivalent of MSBuild.

xbuild /p:Configuration=Release HelloWorld.csproj
0
On

The easiest way is to head over to monodevelop and download their IDE. It can open project files generated by Visual Studio.

Now you can also use the convenience of aptitude as below:

sudo apt-get install monodevelop mono-gmcs
1
On

This question is old and answers are deprectated. I succeed to generate and run DLL from a csproj by following theses steps:

Then, use dotnet build YourProject.csproj to compile the project and dotnet run YourProject.csproj to run it.