If you're fortunate enough to have one of the Visual Studio Team editions, then you have the inbuilt Code Analysis tool that you can run.

Otherwise, you can use the free FxCop tool

But what if you're in a team with a mix of Team Edition and Professional (eg. no Code Analysis)?

Add the following to the bottom of your project files and FxCop will be run on Release builds if you don't have the inbuilt Code Analysis tool installed:

<!-- Run FxCop if available on Release builds, but not if we also have Team Developer -->

<Target Name="AfterBuild" Condition=" ('$(Configuration)' == 'Release') And Exists('$(ProgramFiles)\\Microsoft FxCop 1.35') And !(Exists('$(ProgramFiles)\\Microsoft Visual Studio 8\\Team Tools\\Static Analysis Tools\\FxCop\\FxCopCmd.exe'))">

<Exec Command="FxCopCmd.exe /file:&quot;$(MSBuildProjectDirectory)\\$(OutputPath)$(AssemblyName).dll&quot; /out:&quot;$(MSBuildProjectDirectory)\\$(OutputPath)\\ccnet-fxcop.xml&quot;" WorkingDirectory="$(ProgramFiles)\\Microsoft FxCop 1.35" />

</Target>