[Rider] Adding SonarC# NuGet packages slows down local builds

Hi!

I have also tried to install the SonarAnalyzer.CSharp NuGet package into one of our projects in the solution and added the analyzers to the csproj file with the <Analyzer… tags as described in the link given by Julien Henry (.NET Compiler Platform (Roslyn) analyzers | JetBrains Rider).

This works quite well with the solution wide analysis, but for some reason it slows down the build process dramatically! The project, where I added the analyzers usually need up to 10 seconds to build, but with the analyzers added the build takes 3 minutes!! Even the solution wide analysis does not take so much time…
Is there any chance I can solve this problem. Am I’m doing something wrong? I have added the Google.Protobuf.dll, SonarAnalyzer.CFG.dll, SonarAnalyzer.dll and SonarAnalyzer.CSharp.dll to the Analyzers section in the csproj file (in this order).
Anyone else also had/has this issue?

best regards
Armin

Hi @Armin1979, and welcome to the community.

FYI I’ve split your post into a separate thread because it’s a different topic.

I don’t use Rider so I can’t give a definitive answer, but here are some suggestions as to a possible cause and for some troubleshooting steps.

My guess is that the performance of solution wide analysis seems to be ok is because the analysis is happening in the background so the impact is not obvious. However, the additional time is obvious during builds.

Suggestion (1): try disabling running the analyzers during build

The newer versions of MSBuild v16 now give the option to disable running code analyzers during the build. This is documented here as a Visual Studio feature, but it’s actually implemented at the MSBuild level. I’m not sure in which version of MSBuild this was introduced but I can say it’s not in v15.9 but it is in v16.4.

Suggestion (2): see if the delay is due to a specific SonarC# rule and if so disable it

This post explains how to work out how long each rule is taking to execute.

3 Likes