I am having an issue where the SonarScanner for .NET is not properly scanning one specific project within my solution.
Environment Details
- SonarQube Server v8.9.2
- Sonarscanner for .Net v5.2.1.31210
- Project targets .NET Framework 4.8
Issue Details
One project in my solution, specifically my web applicaiton project, does not appear to be scanning properly. I can view the raw source in the sonar report however this project reports no LoC, rule violations, tests, coverage, etc. All other projects appear to work properly however they are all supporting projects and are either test projects or libraries.
What I Know About the Issue
I have ran the scan with verbose output and I believe I know the cause of the problem however I am at a loss as to how to fix it.
The logs show that my API project is being assigned to the sonar.tests key instead of the sonar.sources.
Here is the relevant output for the project in question
D3B0DC17-A0A9-4D4A-B996-A2B00B723526.sonar.projectName=SafeTraceTx.Api
D3B0DC17-A0A9-4D4A-B996-A2B00B723526.sonar.projectBaseDir=C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Api
D3B0DC17-A0A9-4D4A-B996-A2B00B723526.sonar.sourceEncoding=utf-8
D3B0DC17-A0A9-4D4A-B996-A2B00B723526.sonar.sources=
D3B0DC17-A0A9-4D4A-B996-A2B00B723526.sonar.tests=\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Api\\App_Start\\SwaggerConfig.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Api\\Auth\\App_Start\\Ioc\\Modules\\ApiModule.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Api\\Auth\\App_Start\\Ioc\\Modules\\DomainModule.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Api\\Auth\\App_Start\\Ioc\\Modules\\RepositoryModule.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Api\\Auth\\App_Start\\WebApiConfig.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Api\\Auth\\Attributes\\SafeTraceTxApiAuthorizeAttribute.cs",\
...
Here is the relevant output for a working project
93B784E4-FF9C-4012-AEDA-51649E530624.sonar.projectName=SafeTraceTx.Domain
93B784E4-FF9C-4012-AEDA-51649E530624.sonar.projectBaseDir=C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Domain
93B784E4-FF9C-4012-AEDA-51649E530624.sonar.sourceEncoding=utf-8
93B784E4-FF9C-4012-AEDA-51649E530624.sonar.sources=\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Domain\\Auth\\CommandServices\\ISystemAuthenticationService.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Domain\\Auth\\CommandServices\\SystemAuthenticationService.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Domain\\Auth\\Common\\IJwtTokenUtility.cs",\
"C:\\git-root\\main-sandbox\\app\\SafeTraceTx.Domain\\Auth\\Common\\JwtOverrideTokenDetails.cs",\
Likewise here is the relevant output for the broken projects associated test project
549FBD81-F442-4C1E-BFDB-4EAF3A530DE3.sonar.projectName=SafeTraceTx.Api.Tests
549FBD81-F442-4C1E-BFDB-4EAF3A530DE3.sonar.projectBaseDir=C:\\git-root\\main-sandbox\\app\\Tests\\SafeTraceTx.Api.Tests
549FBD81-F442-4C1E-BFDB-4EAF3A530DE3.sonar.sourceEncoding=utf-8
549FBD81-F442-4C1E-BFDB-4EAF3A530DE3.sonar.sources=
549FBD81-F442-4C1E-BFDB-4EAF3A530DE3.sonar.tests=\
"C:\\git-root\\main-sandbox\\app\\Tests\\SafeTraceTx.Api.Tests\\Auth\\Attributes\\SafeTraceTxApiAuthorizeAttributeTests.cs",\
"C:\\git-root\\main-sandbox\\app\\Tests\\SafeTraceTx.Api.Tests\\Auth\\Attributes\\SafeTraceTxAuthorizeAttributeTests.cs",\
"C:\\git-root\\main-sandbox\\app\\Tests\\SafeTraceTx.Api.Tests\\Auth\\Controllers\\Controllers\\HeartbeatControllerTests.cs",\
"C:\\git-root\\main-sandbox\\app\\Tests\\SafeTraceTx.Api.Tests\\Auth\\Controllers\\Controllers\\LoginControllerTests.cs",\
Does anyone know how the scanner determines if it should set the sources from the project to the sources or tests key? And what might be causing it to miss identify the source project as a test project?