SonarCloud analysis of .NET project times out build

We have a C# project that is timing out when SonarCloud analysis it run on it. Our Azure DevOps pipeline runs a full clean build with SonarCloud analysis on a nightly basis. Since around 7th October one of the projects hangs on the the msbuild step if we have Sonar analysis turned on. It appears to hang on the build step for 40+ minutes before carrying on without error, however the build will fail later after 3 hours when it times out. Without SonarCloud analysis the step takes around 30 seconds.

I’ve rolled the code back to when the analysis was working and the issue persisted leading me to think that we hadn’t introduced an issue in the code. After that I reviewed the rules which have been added since our last working analysis but after removing them I’m still seeing the issue. I have also added the parameters “/p:reportanalyzer=true /v:d > build.log” to msbuild however I’m not seeing the same logs with timings as mentioned in other post on this forum.

Hey there @JStevensBH

There was indeed a release of our .NET analyzer on October 6th (Release 8.30 · SonarSource/sonar-dotnet · GitHub) which was deployed to SonarCloud the next day.

The rules affected in this release were:


Could you try selectively disabling these rules in your Quality Profile to see if one is the obvious cause of the slowdown?

Apologies for the late response, I was on annual leave last week. I will disable them and get back to you with the results

I’ve narrowed it down and the issue is being caused by


While I have deactivated the rule for now we would like to keep our rule set as SonarWay, could you investigate why it is causing our build to hang please

Thanks for the follow-up. I’ve passed this thread onto the right team to take a deeper look.

Hi @JStevensBH,

Do you have any possibility to provide us with a reproducer? The S1854 was reimplemented in 8.30 release.

I can provide a private thread if needed.

Hi @Pavel_Mikula,

To reproduce I run our pipeline with the rule activated and it occurs every time that the services project builds. I have the FilesToAnalyze.txt from where it hangs.

We need to find the code where the time is spent. FilesToAnalyze.txt won’t help here. That one is fully generated before the analysis starts.

Can you use Quality Profile with that rule enabled, disable it with .editorconfig. And then enable it with .editorconfig only for one single directory at a time? Then repeat the same for files in that directory to narrow it down.

It will take quite a bit of time to do what you suggest as it’s about 30 mins into the build process when it hangs. Is there logging I can enable to see how long each rule is taking and where the time is being spent? This could narrow down the over head on my side.

You can set ReportAnalyzer and verbose build log to see how long time each rule takes. See this guide for more details:

As we know that there’s a single rule that causes troubles, you can disable all other rules to save build time.
You can also disable the analysis for each project that doesn’t hang.
The build should be as fast as your build without analysis in case the rule is not causing troubles in that specific test run directory.