Hello everyone. I have just started to test Sonarqube with Unity. After finishing the scan, I did not get much information as my prod code is defined as Test per the warning in the dashboard and in the logs:
WARN: SonarScanner for .NET detected only TEST files and no MAIN files for C# in the current solution. Only TEST-code related results will be imported to your SonarQube/SonarCloud project. Many of our rules (e.g. vulnerabilities) are raised only on MAIN-code. Read more about how the SonarScanner for .NET detects test projects: https://github.com/SonarSource/sonar-scanner-msbuild/wiki/Analysis-of-product-projects-vs.-test-projects
After visiting the forums and read the documentation, I added the TestProject flag to the csproj file, but that has not changed things:
<PropertyGroup> <!-- Project is not a test project --> <SonarQubeTestProject>false</SonarQubeTestProject> </PropertyGroup>
I have seen that you can check how and why it was categorized, but I cannot find the info in my rebuild logs (rebuild command per .NET Framework invocation), the only line that I find with the SonarCategoriseProject said is being skipped (as far as I understood). Would you think is not trying to re-categorize because is skipping it? And if it is, would you advise me on how could I make it not skip?
Target "SonarCategoriseProject" skipped. Previously built successfully.
This is the config I’m using to run Sonarqube:
- Language: C#
- Sonarqube: 126.96.36.199159
- Scanner: MSBuild 188.8.131.52281
- .NET Framework Invocation
- Process: Manual
- Special things: I had to modify around 20 projects to be ignored, as Unity creates multiple of these.
[Scannerlocation]\SonarScanner.MSBuild.exe begin /k:"MyKey" /d:sonar.host.url="http://localhost:9000" /d:sonar.login="token" "[VSlocation]\MsBuild.exe" SolutionName.sln /t:Rebuild /v:diag [Scannerlocation].MSBuild.exe end /d:sonar.login="token"
I ran the begin /d:sonar.verbose=true, and I noticed this on the end logs for a lot of the files within the main project, and I would assume all of them?:
08:48:42.581 DEBUG: 'Assets/Scripts/Items/Gear/GearType.cs' generated metadata as test with charset 'UTF-8' 08:48:42.581 DEBUG: 'Assets\Scripts\Items\Gear\GearType.cs' indexed as test with language 'cs'