Click here to Skip to main content
15,443,982 members
Articles / Programming Languages / C#
Posted 18 Mar 2011


16 bookmarked

Maven Build for .NET Application

Rate me:
Please Sign up or sign in to vote.
3.67/5 (4 votes)
18 Mar 2011CPOL2 min read
How to build a .NET application using Maven


This article describes how to perform the .NET application build in Maven tool. The intent of this article is to tell you how to go about doing a full command-line build of .NET application using Maven. You first need to install the prerequisite application, listed here.


The following applications are used by the different goals, but This article describes only .NET application build and fxcop reports.

ApplicationUsageVersionDownload site
MSBuild.NET sdk install dir2.0, 3.5
Fx Cop.NET code quality reports1.36 +
MavenTo build Run Maven POM2.2.1

The following changes are required after the installation. After the SDK 7 is installed, we need to explicitly run Fxcop application. It will be available in the following location: C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\FXCop and run the fxcop application.

The following environment variables need to be set.

Variable NamePath
FXCOP_HOMEC:\Program Files\Microsoft FxCop 1.35
JAVA_HOMEC:\Program Files\Java\jdk1.6.0_21
PATH*Append : %JAVA_HOME%\bin;

Remember to restart the computer after changing the value of the SYSTEM PATH.

Configure Maven to Run

To configure Maven plugin to run, you need to edit the setting.xml. Open the file from c:\bin\apache-maven-2.2.1\conf\settings.xml and make the change (for your case, location may differ):

  1. Change Maven location repository, otherwise it will be downloaded in your document setting \ .m2... or <localRepository>C:\maven_repository</localRepository>.
  2. Change the Proxy setting according to your organization proxy config example: include the following code to proxy section and change the domain name and IP address:
  3. Include the .NET Profile into the profiles section example:
  4. Add the following code to Properties section:
        c:/Program Files/Microsoft FxCop 1.36

Build the .NET project in the command project with a few modifications to the pom files.

Project Parent Pom

<?xml version="1.0" encoding="utf-8"?>
<project xmlns:xsi= 
xmlns:xsd="" xmlns="">




The above file needs to be created where the project solution is present and below the file, you need to create where the project file is present.

Project Child Pom

<?xml version="1.0" encoding="utf-8"?>
<project xmlns:xsi=""
xmlns:xsd="" xmlns="">

Please ensure that you build and install the parent first (from the parent directory).
Start -> Run -> cmd root to sample project:

C:\MavenBuildTesting\mvn dotnet:clean dotnet:compile install 

Then build and run the goals on the child:

C:\MavenBuildTesting\MavenBuildTesting>mvn dotnet:clean dotnet:compile dotnet:fxcop 

After the successful Maven task, you will be able to see the executable available in the obj directory or project bin release.

If you have any further issues building .NET with Maven, please let me know.


  • 18th March, 2011: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead
India India
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

Questionsample code doesn't work....what's changed? Pin
Member 826232623-Sep-11 6:16
MemberMember 826232623-Sep-11 6:16 
AnswerRe: sample code doesn't work....what's changed? Pin
Rajamohan.Rajendran25-Sep-11 17:18
MemberRajamohan.Rajendran25-Sep-11 17:18 
GeneralRe: sample code doesn't work....what's changed? Pin
Member 826232626-Sep-11 8:37
MemberMember 826232626-Sep-11 8:37 
AnswerRe: sample code doesn't work....what's changed? Pin
Rajamohan.Rajendran26-Sep-11 17:36
MemberRajamohan.Rajendran26-Sep-11 17:36 
GeneralRe: sample code doesn't work....what's changed? Pin
Member 82623265-Oct-11 10:08
MemberMember 82623265-Oct-11 10:08 
General[My vote of 1] good idea (possibly), bad execution Pin
Tieske811-Apr-11 11:13
professionalTieske811-Apr-11 11:13 
GeneralExciting! Pin
JimBlaney18-Mar-11 3:45
MemberJimBlaney18-Mar-11 3:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.