-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
VS2026 builds of our project became drastically slower than VS2022 builds.
We use .NET 9 target framework, and we have this “global.json” in the solution root:
{
"sdk": {
"version": "9.0.0",
"rollForward": "latestFeature"
}
}
Some binlogs are privately attached to https://developercommunity.visualstudio.com/t/VS2026-Rebuild-is-much-slower-than-in-/11027380 where I first reported the problem. There you will also find some time measuring.
Building without analyzers (/p:RunAnalyzersDuringBuild=false) reduced the build time to values similar to VS2022 (still slightly slower).
During analysis of this issue, I found the reportanalyzer switch, and this one brought me to the root cause of the delay I think:
Here are some log snippets (the first line translates to “Total analyzer execution time”):
VS2022:
Gesamtausführungszeit des Analysetools: 10,801 Sekunden.
Zeit (s) % Analysetool
6,212 57 System.Windows.Forms.Analyzers.CSharp, Version=9.0.12.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
6,194 57 System.Windows.Forms.CSharp.Analyzers.AvoidPassingTaskWithoutCancellationToken.AvoidPassingTaskWithoutCancellationTokenAnalyzer (WFO2001)
0,018 <1 System.Windows.Forms.CSharp.Analyzers.MissingPropertySerializationConfiguration.MissingPropertySerializationConfigurationAnalyzer (WFO1000)
2,546 23 Microsoft.CodeAnalysis.CSharp.NetAnalyzers, Version=9.0.12.32904, Culture=neutral, PublicKeyToken=31bf3856ad364e35
VS2026:
Gesamtausführungszeit des Analysetools: 64,305 Sekunden.
Zeit (s) % Analysetool
59,593 92 System.Windows.Forms.Analyzers.CSharp, Version=9.0.12.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
59,572 92 System.Windows.Forms.CSharp.Analyzers.AvoidPassingTaskWithoutCancellationToken.AvoidPassingTaskWithoutCancellationTokenAnalyzer (WFO2001)
0,021 <1 System.Windows.Forms.CSharp.Analyzers.MissingPropertySerializationConfiguration.MissingPropertySerializationConfigurationAnalyzer (WFO1000)
2,385 3 Microsoft.CodeAnalysis.CSharp.NetAnalyzers, Version=9.0.12.32904, Culture=neutral, PublicKeyToken=31bf3856ad364e35
So it seems "System.Windows.Forms.CSharp.Analyzers.AvoidPassingTaskWithoutCancellationToken.AvoidPassingTaskWithoutCancellationTokenAnalyzer" causes the delay.
The file "C:\Program Files\Microsoft Visual Studio\18\Enterprise\MSBuild\Current\Bin\Roslyn\csc.exe" of VS2026 has file version 5.0.26.5402, the same file in VS2022 has 4.1400.25.41205
Adding a ".editorconfig" file with this line optimizes compile time:
dotnet_diagnostic.WFO2001.severity = none