Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I compile a C# solution under maven

Tags:

c#

maven

build

We have an application implemented in two languages, Java and C#. The Java application uses maven for it's build and release process, and now I need to integrate C#'s build into maven as well. It's implemented using Visual Studio 2010. Does anyone know how to do this? What is the best plugin right now that I can use. Thanks a lot!

Update:

So far I found the following 4 options. Has anyone successfully used any of these? Also I will eventually need to port the build/release process to Linux and maybe use Mono to compile in maven. Would appreciate any info, thanks.

NPanday http://incubator.apache.org/npanday/docs/1.2/guide/maven/project-types.html

Plexus http://maven.apache.org/plugins/maven-compiler-plugin/non-javac-compilers.html http://snapshots.repository.codehaus.org/org/codehaus/plexus/plexus-compiler-csharp/1.6-SNAPSHOT/

Maven Dotnet Plugin http://maven-dotnet-plugin.appspot.com/

Tutorial: http://docs.codehaus.org/display/MAVENUSER/Using+Maven+to+manage+.NET+projects

like image 745
dlsou Avatar asked Apr 14 '11 12:04

dlsou


People also ask

How do I compile and run C code?

Step 1: Open turbo C IDE(Integrated Development Environment), click on File and then click on New. Step 2: Write the C program code. Step 3: Click on Compile or press Alt + F9 to compile the code. Step 4: Click on Run or press Ctrl + F9 to run the code.

What is the command to compile C?

Run the gcc command to compile your C program. The syntax you'll use is gcc filename. c -o filename.exe . This compiles the program and makes it executable.

Do you need a compiler to run C?

C is a mid-level language and it needs a compiler to convert it into an executable code so that the program can be run on our machine.

Can you compile C on Windows?

The Visual Studio build tools include a C compiler that you can use to create everything from basic console programs to full Windows Desktop applications, mobile apps, and more.


1 Answers

I work with Maven in a C#/C++ stack. With maven, the general rule of "If it can be done via command-line, it can be done in maven" holds, so we end up having a lot of .bat, .exe and powershell "glue" to get all the pieces playing together.

Probably the best way of managing C# compiles via maven is to create a component that provides the necessary machinery, in the form of powershell scripts or .bat files. You can then either publish this as a maven plugin or simply have all downstream components add a dependency to the "compile component." The syntax is a little tricky to sort out, but at the end of the day, you're just invoking csc.exe or something similar.

I do highly recommend sticking with the basic maven steps - process-resources, compile, test, deploy, release - and what they are meant to do. This will reduce "process noise" between C# and Java code and build processes, since the meaning of mvn compile (for example) will stay conceptually consistent across all components. You'll most likely end up generating .zip files as artifacts instead of .jar files, then unzipping as part of the copy-dependencies step.

When rolling out, expect a LOT of confusion from the C# guys. Maven is completely unfamiliar to 99% of C#/C++ devs in the world, and its process is sufficiently different from a traditional MSBuild/TFSBuild/ANT approach to cause a lot of confusion.

Hope this helps!

like image 138
mcating Avatar answered Nov 02 '22 23:11

mcating