In the next part of the post I will present different issues that I encountered during Sonar configuration.
Where to store custom configuration?
Sonar gives you the possibility to specify different custom configuration at server level or on each project that is analyzed. Personally I prefer to have all the configuration (tools path location, unit tests projects pattern and so on) at project level – in sonar-project.properties file. For me is more easily to manage and if you have two different project that use two different tools, it will be very easily to configure them. Also, on Sonar server multiple person can have access and change the configuration (more teams on the same server). But at sonar-project.properties files, only the team that is working on the project will have access.
Where to put and store the plugins?
In Sonar, for each custom plugin you need to install or setup 3rd part applications or tools. First thing that you ask yourself where should I install and configure them.
I recommend to put all this tools in a folder called “Sonar-Plugins” or something similar. In this way if someone will need to check the plugins resources, change the configuration or configure a new Sonar server, it will be pretty easy to find all the resources and reconfigure them. Also, in this way it will be easier for you to manage them – you don’t need to search each tool in different folders.
What encoding should I set?
When you create the sonar-project.properties files don’t forget to set the encoding of source file to UTF-8. The default encoding is different from the one that is used in .NET projects.
How to exclude setup project?
If you have different project used to create the install package I recommend to use ssonar.exclusion property. Using it, you can specify what folders to be excluded.
How to specify the project name that is displayed in the Sonar dashboard?
To be able to specify a custom name of the project, you need to use the following 3 properties available for this purpose:
How to specify the SLN that needs to be used?
sonar.projectKey=MyFooProject sonar.projectVersion=1.0 sonar.projectName=MyFooProject
In the case you have the SLN project in different location that the sonar-project.properties or you have multiple SLN files under the same folder you can use the following property to specify exactly what SLN should be used:
Ho to specify the Silverlight installation directory?
If you installed Silverlight in a custom location or you have a 64 bits machines, that you will need to specify the location where Silverlight is installed. You can do as in the following example:
How to specify what projects contains the unit tests?
sonar.silverlight.3.mscorlib.location=c:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Silverlight/v3.0 sonar.silverlight.4.mscorlib.location=c:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Silverlight/v4.0 sonar.silverlight.5.mscorlib.location=c:/Program Files (x86)/Reference Assemblies/Microsoft/Framework/Silverlight/v5.0
In general Sonar will detect what are the projects that contains unit tests. In practice this is not happening. Because of this, you will need to specify the project pattern for projects that contains unit test. In the following example you all the projects that contains the ‘Test’ string will be processed as unit tests projects.
What is the configuration pattern when I need to configure different plugins?
All plugins has the same configurations (the general one). To access this properties, you need to use the following path:
In the following example you can see an example that specify the installation directory of a plugin.
How to skip a specific plugin?
If you have a plugin that you don’t want to run you can set the mode of the plugin to ‘skip.
How to specify the installation directory of a plugin?
The installdirectory property is you solution. Don’t forget to use ‘/’ and not ‘\’.
sonar.fxcop.installDirectory=c:/Program Files (x86)/Microsoft Fxcop 10.0
I hope that this tips helped you to configure Sonar.