As this discussion has been moved to a private thread (to be able to share logs and more detailed private information) in the past 5 weeks, I will post here a summary of what’s been discussed:
@aarzoo2001 was kind enough to share with us debug logs of the analysis which is done during MSBuild. Based on this analyis, we’ve noticed that some simple rules were taking too much time, and in the last sprint we’ve improved the performance for 17 of the rules that were behaving particularly bad in their project. SonarCSharp 8.15 has been released on Monday and is expected to be deployed to this week.
we’ve noticed that in the pipeline shared by the customer, the “Prepare Analysis for SonarCloud” task has an impact both on the “Build” and “Run Unit Tests” tasks. Our assumption is that the Unit Test task does the build again, thus invoking the Roslyn analyzers again, instead of using the binaries created in the “Build” task. We’ve suggested to the user either to
– run the code analysis just during the “Run unit tests” task (by moving the “Prepare Analysis…” task after the “Build” task and before the “Unit Test” task)
– run the dotnet test using the –no-build parameter, to avoid doing a second build
We’re waiting for an answer from the user to confirm our assumption.
P.S.: to demistify a bit how our product works:
The “Prepare Analysis for SonarCloud” step does the following:
- downloads the analyzers from and installs them locally in a cache
- creates a .ruleset file based on the Quality Profiles of
- puts a target file in the ImportBefore folder which tells MSBuild to always use the sonar-dotnet analyzers (from the local cache) and passes the rule configuration to the analysis
Then during a build done by MSBuild our Roslyn analyzers get invoked by the Roslyn compiler framework and create the analysis output, which during the “Run Code Analysis” step is read and sent to . Also, the “Run Code Analysis” step does the clean-up of the target file added in the “Prepare…” step.
If you build your project with MSBuild in both “Build” and “Unit Tests…” tasks, then our Roslyn analyzers will get invoked in both.