Example of pom.xml for a .Net solution

Your must first ensure that the settings.xml file is properly configured. See the example of settings.xml for more details.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example.myapplication</groupId>
  <artifactId>example</artifactId>
   <version>1.0-SNAPSHOT</version>
  <name>Example Solution .Net</name>
  <packaging>netpack</packaging>

  <properties>
    <!-- 
       NOTE : the versions and parameters may be defined as properties. 
       Prefer this option to the plugin configuration as it may be accessible to several plugins
    -->
    
    <!-- Name of the solution file, located in the same directory as the pom.xml -->
    <visual.studio.solution>Example.sln</visual.studio.solution>
    
    <!-- Name pattern to recognize the test assemblies, so that unit tests are only launched on those,
    and so that those are excluded from code coverage. Several patterns may be specified using a ";" as delimiter -->
    <visual.test.project.pattern>*.Tests</visual.test.project.pattern>
    
    <!-- Version of the .Net tools, which may be 2.0, 3.5 or 4.0 only
    Default value is 3.5 -->
    <dotnet.tool.version>3.5</dotnet.tool.version>
    
    <!-- Version of silverlight in case the analysed solution contains silverlight project 
    Possible values are 3 and 4
    Default value is 4 -->
    <silverlight.version>4</silverlight.version>
    
  </properties>
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.sonar-plugins.dotnet</groupId>
        <artifactId>maven-dotnet-plugin</artifactId>
        <!-- Plugin specific configuration : commented out here as it is redundant with 
             the properties defined above -->
        <!--
        <configuration>
          <testProjectPattern>*.Tests</testProjectPattern>
          <solutionName>Example.sln</solutionName>
          <toolVersion>3.5</toolVersion>
          <buildConfigurations>
            <buildConfiguration>Debug</buildConfiguration>
            <buildConfiguration>Release</buildConfiguration>
          </buildConfigurations>
        </configuration>
        -->
        
        <!-- Required to enforce a .Net specific maven lifecycle where compile, test and clean are overridden --> 
        <extensions>true</extensions>
      </plugin>
    </plugins>
  </build>
</project>

Below a second example where the sonar plugin has also been configured

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.whatever</groupId>
  <artifactId>my-solution</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <name>My solution</name>
  <packaging>netpack</packaging>

  <properties>
    <visual.studio.solution>MySolution.sln</visual.studio.solution>
    <visual.test.project.pattern>*.Tests;*Test</visual.test.project.pattern>
    <dotnet.tool.version>4.0</dotnet.tool.version>
    <sonar.language>cs</sonar.language>
  </properties>
  
  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.sonar-plugins.dotnet</groupId>
        <artifactId>maven-dotnet-plugin</artifactId>
        <extensions>true</extensions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>sonar-maven-plugin</artifactId>
        <configuration>
          <language>cs</language>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Now an example with dependencies and package settings

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.whatever</groupId>
  <artifactId>my-solution</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <name>My solution</name>
  <packaging>netpack</packaging>

  <properties>
    <visual.studio.solution>MySolution.sln</visual.studio.solution>
    <visual.test.project.pattern>*.Tests;*Test</visual.test.project.pattern>
    <dotnet.tool.version>4.0</dotnet.tool.version>
    <sonar.language>cs</sonar.language>
        
    <!-- Assembly Search Path file name. Should be imported with <Import Project=".\asp.target"/> at the end of csproj files -->
    <dotnet.asp.file>./asp.target</dotnet.asp.file>
        
    <!- Package construction patterns -->       
    <dotnet.pack.files>
          files=./test/**/*.*        to-dir=test 
          files=./Release_Notes.txt  to-dir=.
          files=./build/dlls/*.*     to-dir=dlls
    </dotnet.pack.files>        
  </properties>
    
  <dependencies>
     <dependency>
        <groupId>com.whatever</groupId>
        <artifactId>log4net</artifactId>
        <version>1.2.10</version>
        <type>sln</type>
     </dependency>
     <dependency>
        <groupId>com.whatever</groupId>
        <artifactId>my-dep</artifactId>
        <version>1.0</version>
        <type>sln</type>
     </dependency>
  </dependencies>   
</project>

Now an example with dependencies and package settings

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.whatever</groupId>
  <artifactId>my-solution</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <name>My solution</name>
  <packaging>netpack</packaging>

  <properties>
    <visual.studio.solution>MySolution.sln</visual.studio.solution>
    <visual.test.project.pattern>*.Tests;*Test</visual.test.project.pattern>
    <dotnet.tool.version>4.0</dotnet.tool.version>
    <sonar.language>cs</sonar.language>
        
    <!-- Assembly Search Path file name. Should be imported with <Import Project=".\asp.target"/> at the end of csproj files -->
    <dotnet.asp.file>./asp.target</dotnet.asp.file>
        
    <!- Package construction patterns -->       
    <dotnet.pack.files>
          files=./test/**/*.*        to-dir=test 
          files=./Release_Notes.txt  to-dir=.
          files=./build/dlls/*.*     to-dir=dlls
    </dotnet.pack.files>        
  </properties>
    
  <dependencies>
     <dependency>
        <groupId>com.whatever</groupId>
        <artifactId>log4net</artifactId>
        <version>1.2.10</version>
        <type>sln</type>
     </dependency>
     <dependency>
        <groupId>com.whatever</groupId>
        <artifactId>my-dep</artifactId>
        <version>1.0</version>
        <type>sln</type>
     </dependency>
  </dependencies>   
</project>

Now an example with dependencies and package settings

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.whatever</groupId>
  <artifactId>my-solution</artifactId>
  <version>1.2.3-SNAPSHOT</version>
  <name>My solution</name>
  <packaging>netpack</packaging>

  <properties>
    <visual.studio.solution>MySolution.sln</visual.studio.solution>
    <visual.test.project.pattern>*.Tests;*Test</visual.test.project.pattern>
    <dotnet.tool.version>4.0</dotnet.tool.version>
    <sonar.language>cs</sonar.language>
        
    <!-- Assembly Search Path file name. Should be imported with <Import Project=".\asp.target"/> at the end of csproj files -->
    <dotnet.asp.file>./asp.target</dotnet.asp.file>
        
    <!- Package construction patterns -->       
    <dotnet.pack.files>
          files=./test/**/*.*        to-dir=test 
          files=./Release_Notes.txt  to-dir=.
          files=./build/dlls/*.*     to-dir=dlls
    </dotnet.pack.files>        
  </properties>
    
  <dependencies>
     <dependency>
        <groupId>com.whatever</groupId>
        <artifactId>log4net</artifactId>
        <version>1.2.10</version>
        <type>sln</type>
     </dependency>
     <dependency>
        <groupId>com.whatever</groupId>
        <artifactId>my-dep</artifactId>
        <version>1.0</version>
        <type>sln</type>
     </dependency>
  </dependencies>   
</project>