SonarQube Enterprise EditionVersion 9.9.1 (build 69595)
SonarScanner for MSBuild 5.15
.NET Core version of the Scanner for MSBuild
deployed via Docker
I have a dotnet repo with 10 project folders.
When I did a main branch scan, the Sonar project showed only 3 folders.
When I did a pull request scan (which added 2 new folders), the Sonar project for that branch showed 10 out of 12 folders, even though the two missing folders had code changes.
When that PR was merged to main, the Sonar project code overview showed the same 10 folders (out of 12)
Here’s how we invoke the main branch scan:
dotnet sonarscanner begin /k:“Xello.CalendarEvents.API” /n:“Xello.CalendarEvents.API” /d:sonar.host.url=“http://10.7.0.4:9000 ” /d:sonar.scm.provider=“git” /d:sonar.login=“****” /d:sonar.sourceEncoding=“UTF-8” /d:sonar.cs.opencover.reportsPaths=“**/TestResults/**/coverage.opencover.xml” /d:sonar.cs.vstest.reportsPaths=“**/TestResults/vstest.results.trx”
And here’s how we invoke the pull request scan:
dotnet sonarscanner begin /k:“Xello.CalendarEvents.API” /n:“Xello.CalendarEvents.API” /d:sonar.host.url=“http://10.7.0.4:9000 ” /d:sonar.scm.provider=“git” /d:sonar.login=“****” /d:sonar.sourceEncoding=“UTF-8” /d:sonar.cs.opencover.reportsPaths=“**/TestResults/**/coverage.opencover.xml” /d:sonar.cs.vstest.reportsPaths=“**/TestResults/vstest.results.trx” /d:sonar.qualitygate.wait=true /d:sonar.qualitygate.timeout=900 /d:sonar.pullrequest.key=“11” /d:sonar.pullrequest.branch=“ENG-65156-educator-create-event” /d:sonar.pullrequest.base=“main” /d:sonar.pullrequest.github.repository=“CareerCruising/Xello.CalendarEvents.API”
The repo has no sonar-project.properties, and the .csproj files don’t have any Sonar config.
I have attached a verbose sonar scan from a local (docker) run of this project.
I see that there are some clues in there.
For one thing, the missing project folders are:
CalendarEvents.HigherEdUser.API
Xello.CalendarEvents.Student.API
… and files from these project folders (and no other project folders) appear in the sonar.sources value in the dumped content of sonar-project.properties (line 183)
sonarscan-verbose.log (253.3 KB)
Colin
(Colin)
October 10, 2024, 11:34am
2
Hey there.
It looks like these projects only include .json
files. SonarQube does not analyze these by default.
sonar.sources=
“C:\workspace\xello\Xello.CalendarEvents.API\.config\dotnet-tools.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\.sonarlint\Xello.CalendarEvents.API.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\.vscode\settings.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\appsettings.Development.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\appsettings.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\appsettings.Development.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\appsettings.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\obj\project.assets.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\obj\Xello.CalendarEvents.HigherEdUser.API.csproj.nuget.dgspec.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\Properties\launchSettings.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\obj\project.assets.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\obj\Xello.CalendarEvents.Student.API.csproj.nuget.dgspec.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\Properties\launchSettings.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\bin\Debug\net8.0\appsettings.Development.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\bin\Debug\net8.0\appsettings.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\bin\Debug\net8.0\Xello.CalendarEvents.HigherEdUser.API.deps.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\bin\Debug\net8.0\Xello.CalendarEvents.HigherEdUser.API.runtimeconfig.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\obj\Debug\net8.0\staticwebassets.build.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.HigherEdUser.API\obj\Debug\net8.0\Xello.CalendarEvents.HigherEdUser.API.sourcelink.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\bin\Debug\net8.0\appsettings.Development.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\bin\Debug\net8.0\appsettings.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\bin\Debug\net8.0\Xello.CalendarEvents.Student.API.deps.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\bin\Debug\net8.0\Xello.CalendarEvents.Student.API.runtimeconfig.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\obj\Debug\net8.0\staticwebassets.build.json”,
“C:\workspace\xello\Xello.CalendarEvents.API\Xello.CalendarEvents.Student.API\obj\Debug\net8.0\Xello.CalendarEvents.Student.API.sourcelink.json”
Do you expect to see .cs
files in these directories?
Yes, Xello.CalendarEvents.Student.API has a dozen .cs files
$ find Xello.CalendarEvents.Student.API -name *.cs | wc -l
12
Here’s the property group from that project’s csproj. (The two missing projects have identical properties to Xello.CalendarEvents.Educator.API, which is scanned property.)
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RuntimeIdentifiers>win-x64</RuntimeIdentifiers>
<IsPackable>true</IsPackable>
</PropertyGroup>
The solution and project files are read and built properly within Visual Studio:
Colin
(Colin)
October 10, 2024, 2:39pm
4
Thanks.
Forgive maybe a dumb question, but when I look at the logs you shared I only see a dotnet test
. Where’s the dotnet build
? This should be a clean build (--no-incremental
)
That turns out to be exactly the right question.
We are doing “dotnet test”, which does an implicit build, but it obviously doesn’t build everything.
When I added the “dotnet build --no-incremental” the “missing” folders are found.
Thank you.
1 Like
system
(system)
Closed
October 17, 2024, 3:50pm
6
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.