Skip to end of metadata
Go to start of metadata

This page is a work in progress. Do not hesitate to share your tips and tricks to improve this page.

If you encounter any trouble analyzing a C# project, first try to rerun the analysis adding "-X" to the command line in order to get a verbose output then ask for help to the users mailing list. Please do not open a JIRA ticket before sending emails to the users mailing list.

Analysis succeeds but tests metrics do not appear on the dashboard

Obviously this happens when Gallio has failed during the analysis. There are several possible causes, below a few of them:

  1. You are running the analysis on a 64b box using partcover. Please follow the FAQ page in order to solve the problem with command line corflag tool.
  2. The test framework used by the analyzed Visual Studio solution is incompatible with the version of Gallio used during the analysis. This happens if you are using a quite old version of Gallio with a brand new version of Nunit. Easy fix : upgrade Gallio.
  3. The coverage tool (i.e. NCover, Partcover...) has failed during test execution. Again check the verbose logs. Changing the gallio runner config property may help in this case.
    For example, if you are using MsTest and if you get Microsoft.VisualStudio.TestTools.TestManagement.InvalidStorageExtensionException error messages,  try to rerun the analysis setting property sonar.gallio.runner to IsolatedProcess (thanks mathieu Lagace for the tip)

Analysis succeeds but too few issues are found

Some tools like FxCop or Gendarme need compiled assemblies to perform analysis. In other words, they do not work on source code. Having too few issues most often comes from the following reasons:

  • the Visual Studio solution hasn't been compiled prior to the SonarQube analysis - whereas this is clearly mentionned in the documentation that it should

OR

  • the solution has been compiled but the corresponding generated assemblies have been moved somewhere else (because of a specific build process) and SonarQube can't find them

OR

  • the solution has been compiled and the assemblies haven't been moved, but the whole solution folder has been moved to another location (and therefore the debug PDB files don't point to the original source locations)

Analysis succeeds but only one test assembly/project is taken into account

If you are using NCover, you may have purchased the "Classic edition". Only the "Complete edition" allows to run tests from several assemblies and merge the coverage data. You can activate the "gallio safe mode" and the SonarQubeGallio plugin will merge the coverage data. See the Gallio configuration page for more details.

0% code coverage using reuse reports mode

This might happen if you have generated the reports then moved the files of your Visual Studio solution. In the XML coverage files, the paths to the C# source files must be the same as the paths specified in the csproj files of the analyzed solution, otherwise the coverage date are simply not taken in account.

OpenCover is activated and Gallio fails without any explanation

OpenCover needs .net framework 4 in order to run. If you try to use OpenCover without .net4 installed, the analysis will crash. 

When using OpenCover with Gallio, I get 0% code coverage whereas I do have test classes that are covered by tests

Most probably, you should use the following property to run the tests in an isolated process:

Gallio execution fails with following error message

This error happens when one of the dotnet config files (app.config, web.config, ...) of your Visual Studio solution specifies a runtime version not supported by the instance of Gallio used. This is often the case when the following XML fragment appears in a app.config file:

The "sku" attribute is not something understandabe by Gallio... If you remove the above XML fragment by the one below the problem is solved :

Thanks a lot to Stéphane Lopes for the tip.

Gallio execution fails on a Windows 64bits system

If in the logs you get something such as:

that might be because some of your assemblies have been compiled with a x86 profile (32 bits) while Gallio is configured to run in an "Any CPU" mode, hence 64bits on your system.
This problem might be solved using corflags tool to force Gallio to run in a 32 bits mode as shown below:

Some tests fail unexpectedly using a legacy .net2 library

If you get this kind of error :

There are strong chances you are in the situation described here

The problem might be solved if you modify your installation of gallio. Add the following XML fragment in files Gallio.Host.x86.exe.config and/or Gallio.Host.x64.exe.config :

Why do I get MSBuild error such as "error MSB4126: The specified solution configuration "Debug|HPD" is invalid"

You are using a 64 bit windows OS. There is an environment variable "Platform=HPD" that makes msbuild fail. Try to run "set platform=[enter]" then "mvn sonar:sonar..."

On Windows7 I get "The Silverlight 3/4 SDK is not installed" error messages

64bits msbuild cannot be used with silverlight. Check that you are not using a 64bits msbuild by taking a look at properties dotnet.3.5.sdk.directory anddotnet.4.0.sdk.directory. "Framework64" should not be present in the path.

The analysis fails with an OutOfMemory exception

The java process performing the code analysis might need more RAM. Use the "-Xmx" option to specify the amount of memory that can be use. See the SonarQube Runner documentation for more details

I get many false positives for gendarme rule AvoidVisibleFieldsRule

This rule works at class level. If you are working on a windows form or asp.net project, you may have many partial classes. The code generated in the "designer" parts may contain many "visible fields" whereas the real code that matters does not contain any defects. In order to avoid these false positives, you have two options:

  1. Disable this rule. Probably not the best option.
  2. Use the Switch Off  Violations plugin to disable the rule only on "view" related components.

On an asp.net project you may configure the Switch Off violations plugin as follow: