Usage of Maven Dotnet Plugin

In order to use the plugin, you must install the following prerequisite application on the machine and define the associated properties in the maven settings.xml file, either in the $M2_HOME/conf/ directory (recommended as it is mostly machine-specific) or in $HOME/.m2 directory.


To use the different goals, you must first install the .Net framework if it is not bundled in your system.

Prerequisite applications

The following application are use by the different goals:

Application PropertyUsageSupported VersionDownload site
MSBuilddotnet.3.5.sdk.dir.Net sdk install dir2.0, 3.5 test runner3.1 Update 2 + code coverage2.2, 2.3 and 4.0
NCoveruseNCover (boolean).Net code coverage3.0
Source Monitorsourcemoniter.directoryC# code metrics2.5 +
Fx code quality reports1.36 +
Style Cop *stylecop.directoryC# code style report4.3+
Mono Gendarme ** code quality reports2.10+

* Style Cop 4.4 is bundle with the maven dotnet plugin since version 0.3 . Thus installation of Style Cop is not mandatory.

** Gendarme 2.10 is bundle with the maven dotnet plugin. Thus installation of Gendarme is not mandatory.


There is a bug in the coverage reports generated by PartCover 2.3 and 4.0 (prior to version 4.0.11013), in which the source files that have no line covered are excluded, and thus, the coverage percentage only corresponds to the coverage of ... the covered files :-(

NCover is a commercial alternative to PartCover. After having installed NCover3, you can activate it for sonar by setting property useNCover to true. NCover3 has the advantages of not suffering from the bug described before and working perfectly on a 64bit OS.

Indeed, if you are using a 64bit OS with PartCover, you need to play a little bit with tool CorFlags.exe as it is described here :

PartCover.exe and Gallio.Echo.exe need to be modified using CorFlags.

Project configuration

To use the plugin, you just need to add a pom.xml in the root folder of the .Net solution, in the directory where the '.sln' file is located as described in this example.

You will also need to provide a path to the installation of .Net, and other tools if required for the different generated reports as described here.

An example of file tree for a solution

Here is a file tree of a standard .Net solution on which Maven is activated:

  + my-solution.sln 
  + pom.xml
  + example-project
  |     |
  |     + example-project.csproj
  |     |
  |     + namespaces...
  + other-project
        + other-project.csproj