Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 658
Alasdair Avatar asked Nov 25 '11 02:11

Alasdair


People also ask

How do I compile and run C code in Visual Studio?

After stopping the C file, go & click the File button at the top left corner of the Visual Studio Code Editor, and select the Settings via Preferences, as shown below image. After clicking the Settings, it shows the image below. In this image, select the extension button to set the settings for the C Compiler.

How do I compile C in Visual Studio community?

You don't have to be using the IDE to compile C. You can write the source in Notepad, and compile it in command line using Developer Command Prompt which comes with Visual Studio. Open the Developer Command Prompt, enter the directory you are working in, use the cl command to compile your C code.


1 Answers

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).

like image 187
knocte Avatar answered Oct 06 '22 12:10

knocte