Search code examples
c#msbuildsonarqubesonar-runner

C# - Sonar scanner for msbuild with multiple configuration


I have an C# solution which has 2 configuration and i have one Sonarqube project.

I am running sonar scanner like below:

sonar-scanner for ms-build begin

ms-build -config:config_1 MySolution.sln

ms-build -config:config_2 MySolution.sln

sonar-scanner for ms-build end

Is this procedure right? can i include two ms-build for same solution with two configuration?

Do i miss any issues if i do that?


Solution

  • Yes, as long as you are using v4 of the Scanner for MSBuild or later.

    This feature was actually added to support .NET Core projects that target multiple frameworks, but it also works when building two different project configurations e.g. DEBUG and RELEASE.

    You won't miss any issues - the issues will be de-duplicated and merged. However, calculating metrics is more complicated when using conditional compilation, so the scanner takes the simple approach and just uploads the metrics for a single configuration. See the blog post about the release for more information.