I have VS 2010 Professional (which, unlike Premium, does not include access to Code Analysis configuration within the IDE), and a C# 4 solution containing many-dozen projects. I want to do static code analysis as part of solution compilation.
The possible ways I have identified with the help of SO and Google are:
Edit every
.csproj
in the solution to include an invocation of the stand-alone FxCop 10 as a Post-build event. Pros: happens on every compile for every project that is rebuilt. Cons: Have to take additional measures to ensure new projects have this specifiedCreate a new project, or identify an existing project, that is always built last, on account of its project dependencies. Give (just) that project a Post-build event that runs FxCop on all the assemblies in the (common) output folder. Pros: only one file to update, and less possibility of future projects going unanalysed. Cons: The vagaries of build dependencies might mean this doesn't actually work
Update all developers' VS instances with an add-in or macro that runs FxCop after any build. Don't really like this idea at all.
Are there any other options, that are clearly better than any of the above? Are there any caveats or observations I need to be aware of to make one of the above work?
I also want FxCop to be run as part of a MSBuild 4.0
-powered build on a build server. Which of the options will allow me to reuse code analysis rulesets between desktop compilation and bulid server compilation?
I have already read related but non-identical already-existing questions including:
- FxCop for .NET 4.0 which asks 'is the stand-alone FxCop available yet?'
- FxCop on build (Visual Studio 2008 Professional) which is about a single project
- How to integrate FxCop and VS 2008? which is about making FxCop-invocation available ad hoc, on a context menu click