I've setup a separate build configuration that doesn't run code analysis.
I now have the following configurations in VS:
- Release
- Debug
- Debug (No code analysis)
You have to manually choose which configuration you want to build (i.e. step 3 in your list would be a manual step)
In the build targets file I've included code along these lines:
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<RunCodeAnalysis>true</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug (No code analysis)' ">
<RunCodeAnalysis>false</RunCodeAnalysis>
</PropertyGroup>
<PropertyGroup>
<DefineConstants Condition="('$(RunCodeAnalysis)'=='true') and '$(Language)'=='C#' ">CODE_ANALYSIS;$(DefineConstants)</DefineConstants>
</PropertyGroup>