Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Best practices and guidelines to know
Code Block
languagenone
sonar.fxcop.mode=skip
sonar.gendarme.mode=skip
sonar.gallio.mode=skip
sonar.ndeps.mode=skip
Note
title

Best Practices

  • As you've already read in the requirements, your solution must be compiled before running a Sonar analysis. However, please note that Sonar's primary goal is to analyse source code, so everything has been made to work seamlessly right after the compilation of a solution and before any packaging made by a build process. In other words, if you have build processes that move the compiled DLL or executables and package your application, it is definitely best to run Sonar before those steps (or in a separate process) otherwise you may run into troubles with over-complicated configuration of the C# plugins.
  • It is best to run the analysis from within the folder that contains the SLN file, in order to simplify the configuration of the C# plugins (e.g.: in such case, you do not need to tell where to find the SLN file).

Running a Sonar Analysis with the Sonar Runner (Recommended Way)

  1. Create a 'sonar-project.propeties' file and place it in the same folder as the Solution file (".sln").
    Here is the simplest 'sonar-project.properties' file that you can write to be able to run a Sonar analysis on your project:

    Code Block
    titlesonar-project.properties
    languagehtml/xml
    # Project identification
    sonar.projectKey=com.mycompany:myCSharpApplication
    sonar.projectVersion=1.0-SNAPSHOT
    sonar.projectName=My C# Application
    
    # Info required for Sonar
    sonar.sources=.
    sonar.language=cs
    



  2. Run the following command from your Solution folder:

    Code Block
    languagenone
    sonar-runner

...

As it used to be the case for the .NET Plugins, Maven can be used to launch Sonar analyses on your C# code base.
If you are familiar with maven, you can also use the maven-dotnet-plugin in order to compile and package dotnet projects. If you already use a CI tools tool such as Jenkins or Hudson on java maven Java Maven projects, you can use the maven-dotnet-plugin to handle dotnet .Net projects the same way

The POM file

...