# SonarCloud analysis of .NET project times out build

**URL:** <https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408>\
**Category:** SonarQube Cloud\
**Tags:** performance, dotnet, scanner\
**Created:** [November 18, 2021, 3:10pm UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408 "2021-11-18T15:10:40Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![JStevensBH](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@JStevensBH](https://community.sonarsource.com/u/JStevensBH)\
**Post date:** [November 18, 2021, 3:10pm UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/1 "2021-11-18T15:10:40Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 23, 2021, 9:51am UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/3 "2021-11-23T09:51:43Z")

</div>

Hey there @JStevensBH

There was indeed a release of our .NET analyzer on October 6th ([Release 8.30 · SonarSource/sonar-dotnet · GitHub](https://github.com/SonarSource/sonar-dotnet/releases/tag/8.30.0.37606)) which was deployed to SonarCloud the next day.

The rules affected in this release were:

`csharpsquid:S1172`  
`csharpsquid:S1854`  
`csharpsquid:S2190`  
`csharpsquid:S3604`

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

---

<div class="post-metadata">

**Author:** ![JStevensBH](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@JStevensBH](https://community.sonarsource.com/u/JStevensBH)\
**Post date:** [November 29, 2021, 9:34am UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/4 "2021-11-29T09:34:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JStevensBH](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@JStevensBH](https://community.sonarsource.com/u/JStevensBH)\
**Post date:** [November 30, 2021, 11:17am UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/5 "2021-11-30T11:17:10Z")

</div>

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

csharpsquid:S1854

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

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [November 30, 2021, 1:06pm UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/6 "2021-11-30T13:06:19Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pavel\_Mikula](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pavel_mikula/32/7381_2.png) [@Pavel\_Mikula](https://community.sonarsource.com/u/Pavel_Mikula)\
**Post date:** [December 1, 2021, 10:42am UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/7 "2021-12-01T10:42:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JStevensBH](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@JStevensBH](https://community.sonarsource.com/u/JStevensBH)\
**Post date:** [December 1, 2021, 11:13am UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/8 "2021-12-01T11:13:57Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pavel\_Mikula](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pavel_mikula/32/7381_2.png) [@Pavel\_Mikula](https://community.sonarsource.com/u/Pavel_Mikula)\
**Post date:** [December 1, 2021, 4:50pm UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/9 "2021-12-01T16:50:41Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JStevensBH](https://avatars.discourse-cdn.com/v4/letter/j/b5a626/32.png) [@JStevensBH](https://community.sonarsource.com/u/JStevensBH)\
**Post date:** [December 2, 2021, 9:47am UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/10 "2021-12-02T09:47:06Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Pavel\_Mikula](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/pavel_mikula/32/7381_2.png) [@Pavel\_Mikula](https://community.sonarsource.com/u/Pavel_Mikula)\
**Post date:** [December 2, 2021, 12:10pm UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/11 "2021-12-02T12:10:11Z")

</div>

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

> [@The Sonar guide for investigating the performance of .NET analysis](https://community.sonarsource.com/t/the-sonarsource-guide-for-investigating-the-performance-of-net-analysis/47279#read-the-logs-6):
>
> This guide is intended to help SonarQube users investigate .NET analysis performance issues. This effort can lead to: self-diagnose and fix a performance issue gather information to [open a well-defined topic](https://community.sonarsource.com/t/the-sonar-guide-for-investigating-the-performance-of-net-analysis/47279#p-133746-report-a-performance-problem-37) on this community forum help SonarSource improve the performance of the products Before discussing how to investigate performance issues, you should first understand the different steps of the analysis. Introduction to the SonarSource .NET static analysis State-of-the-art static analysis …

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.

---

<div class="post-metadata">

**Author:** ![Caba\_Sagi](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/caba_sagi/32/17409_2.png) [@Caba\_Sagi](https://community.sonarsource.com/u/Caba_Sagi)\
**Post date:** [February 24, 2022, 3:06pm UTC](https://community.sonarsource.com/t/sonarcloud-analysis-of-net-project-times-out-build/53408/12 "2022-02-24T15:06:24Z")

</div>


