20

My VS.NET 2008 solution is taking longer and longer to compile (ASP.NET 3.5 + ASP.NET MVC 2 + C#) and I am wondering if there is a way to know what project takes the longer to compile and why? I disabled the compilation of a few projects and it helped reduce the build time but I want it faster.

Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249
Martin
  • 39,309
  • 62
  • 192
  • 278
  • See also http://stackoverflow.com/questions/55517/very-slow-compile-times-on-visual-studio – nos Aug 11 '10 at 20:50

3 Answers3

19
Tools -> Options... -> Projects and Solutions -> Build And Run

Then change MSBuild project build output verbosity

When on normal (defaul is minimal) it gives timings for each project, so this could be used to pin point what is causing the slow down. (Assuming you use the Output window)

Or adjust to a higher level to see more detail of what is going on during a compile.

BullyWiiPlaza
  • 17,329
  • 10
  • 113
  • 185
PostMan
  • 6,899
  • 1
  • 43
  • 51
  • 1
    In my case, the msbuild timing is between 1 and two seconds, while the project takes 80 seconds for some unknown thing before it is handed to msbuild. – Alireza Aug 23 '12 at 08:15
8

You can use MSBuild Profiler to get a breakdown of how long each project and it's tasks are taking. It's a little old and doesn't seem to be supported but I've still found it very useful. Download and install from here then run as follows from the VS command line:

MSBuild.exe MySolution.sln /l:MSBuildProfileLogger,MSBuildProfiler,Version=1.0.1.0,Culture=neutral,PublicKeyToken=09544254e89d148c

When it finishes it will pop-up a GUI with a tree structure breakdown of your solution, containing the time it took to process each project and task.

Scott Lerch
  • 2,620
  • 1
  • 23
  • 34
  • 2
    I personally didn't have any luck with this - was getting lots of NullReference exceptions - granted this codeproject is ancient by now. You may find [MSBuildStructuredLog somewhat useful](https://github.com/KirillOsenkov/MSBuildStructuredLog). My slowdown turned out to just be Windows Defender (MsMpEng.exe) hogging disk usage by scanning during build time - verified via procmon. – SliverNinja - MSFT Apr 17 '18 at 14:04
2

@PostMan's answer is what you need (hence my +1 on that)

The MSBuild (4.0) debugger may also prove useful

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
Ruben Bartelink
  • 59,778
  • 26
  • 187
  • 249