Visual studio 22 slow Build time with .net core 6
Asked Answered
C

1

6

after migration from .net core 2.1 to .net core 6.0, the build time became slow,takes about 1:30 (1 minute and 30 seconds) . by using MSBuild Log Viewer (https://msbuildlog.com/) the result was that most expensive task is CoreCompile, it takes (1:22) from (1:30) (can see build logs image below).

and in output window can see the build stuck in

C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\Roslyn\csc.exe

after Determine the most expensive task what is the next step to reduce the build time ? Any help would be much appreciated.

important notice (the build time for same project using same MSBuild in version .net core 2.1 is ( 16 seconds only ) but after migrate to .net core 6.0 for the project build time is ( 1:30 ))

enter image description here

Catabolite answered 23/6, 2022 at 13:50 Comment(7)
"after Determine the issue " - Roslyn\csc.exe looks like compiler itself, so I would not say that you have determined the issue.Kinematics
@GuruStron the build time for same project using same MSBuild and compiler in version .net core 2.1 is ( 16 seconds only ) but after migrate to .net core 6.0 for the project build time is ( 1:30 )Catabolite
I recommend to create a minimal reproducible example and create a bug for roslyn team.Kinematics
i mean if its compiler issue, so why when build the same project in ( .net core 2.1 version ) the build time is normal ( 16 secons ) , In spite of the both vesions using the same compiler.Catabolite
Can you install ProcMon, set a filter for csc.exe and compile again?Maritamaritain
For starters try deleting all bin and obj folders from the solution (or if you use git - commit all changes to the branch and do git clean -fdx) and rebuild the solution.Kinematics
@GuruStron i really appreciate your recommendations , i will try it and inform you, thanks alotCatabolite
M
3

In my experience, a lot of time the slow compilation times are caused by some slow analyzer (even the ones shipped by MS can be slow).

You can get detailed diagnostics about how various analyzers affect your build time by running your build with the /p:ReportAnalyzer=true MSBuild property, while logging(via the /bl flag) & viewing the resulting binlog.

Mlle answered 30/10, 2022 at 20:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.