views:

161

answers:

2

We have a solution with 15 projects, which all has code analysis enabled.

The solution easily takes 60+ seconds to build, which is a very long time when sitting waiting.

If I disable code analysis it builds in 10 sesonds.

I would love to be able to disable code analysis on an ad-hoc basis. But still I want code analysis when building before check-in, and also I want our Build Server (Cruise Control) to continue running with Code analysis enabled.

I'd prefer if code analysis is running from within Visual Studio, so I can jump directly to the source code if I get an error/warning.

A: 

We had that sort of problem with our stuff. We just got everyone quad 64bit processors and between 8 an 16GB ram. Plus we tried to limit the number of projects at any one point. Not the most graceful solution but it helped a lot.

Rob
+4  A: 

Here's how we do it:

  • Disable (or rather: do not enable) Code Analysis (CA) for Debug builds.
  • Create a new Build Configuration called Verify where Code Analysis is enabled, and warnings are treated as errors.
  • Keep Release build as is.

We do our normal development in Debug mode, and simply have an informal rule that you must pass a Verify build before you check in.

This is easy to forget, but we run Continuous Integration (CI) on the Verify build, so if you check in code that has Code Analysis warnings, you break the build - so people quickly learn to do a manual Verify build before checking in :)

You can also just use Debug without CA and Release with CA, but since enabling CA defines the CODE_ANALYSIS constant, it means that CA Suppressions will be included in the IL, and I prefer not having that in my Release binaries (YMMV).

Mark Seemann
For information about CA Suppressions in the IL, check out http://msdn.microsoft.com/en-us/library/ms244717(VS.80).aspx
Steven Sudit