.NET project forced into sonar.tests category

Using SonarQube 8.6 (build 39681)
Using SonarScanner.MSBuild

Trying to run scan and upload analysis results to SonarQube for a project named (generically) Company.Testing.Library. The name appears to be forcing it to be recognized as a test project and the logs indicate that all files under that path are associated with the sonar.tests property. Result: none of the source files are listed under the Code section in SonarQube and the analysis produces no results.

I have tried the following:

  • adding my directory to sonar.sources parameter
  • setting sonar.tests to the unit test directory (Company.Testing.Library.Tests)
  • adding my directory to sonar.inclusions both on the command line and in the project properties on the server
  • set sonar.msbuild.testProjectPattern to “Company.Testing.Library.Tests” from the command line /d:sonar.msbuild.testProjectPattern=“Company.Testing.Library.Tests”
  • combinations of all the above

I’m still not able to get the source files scanned. Is there a way to achieve this or am I forced to rename the .NET project?

Hi @cnewton ,

Welcome to SonarSource Community! :sonarsource:

Please review this and see if it helps: Analysis of product projects vs. test projects · SonarSource/sonar-scanner-msbuild Wiki · GitHub



Thanks, Joe! That looks quite helpful. I’ll try the project property exclusion/inclusion approach and let you know how it goes.

1 Like

Thanks, Joe! Adding the following to the .csproj file fixed the issue:

  <!-- Project is not a test project -->
1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.