CodeAnalysis, FxCop and Team Build
Team Build has a different interpretation for RunCodeAnalysis flag. The standard definition (interpreted by Visual Studio) treats it as boolean value that can be set to true or false. FxCop task will be executed with build only if this flag is set true.
Team Build implements RunCodeAnalysis as three ways flag. The allowed values of this flag are "Default"/"Always"/"Never". You can set this flag manually for your build type by editing TeamBuild.proj file. You can set the value of flag to either "Default" or "Never" using Team Build client. You have to manually edit TeamBuild.proj file to set the flag value to “Always”.
Example scenario
If you are building a solution (sln) containing three projects. The first project (csproj file) has RunCodeAnalysis flag set to true. The second project has RunCodeAnalysis flag set as false and the third project (csproj) does not define this flag at all.
- if ( RunCodeAnalysis = = “Default” )
Team Build will run FxCop based on individual project settings. In our example scenario, FxCop will be run for only for first project.
- if ( RunCodeAnalysis = = “Never” )
Team Build will override the individual project settings and FxCop will not run for any project.
- if ( RunCodeAnalysis = = “Always” )
Team Build will override the individual project settings and FxCop will run for all projects.
- if ( ( RunCodeAnalysis ! = “Always” ) AND ( RunCodeAnalysis ! = “Never” ))
Set RunCodeAnalysis = “Default"
Disclaimer: The information mentioned is for beta3 bits (releasing in September 2005).
Comments
Anonymous
September 24, 2007
Thanks to the MSDN forums (and specifically one Hua Chen), I found a way to disable specific code analysisAnonymous
January 30, 2008
How to Include custum Fxcop rules stored in XML file in TFSbuild script .Anonymous
February 07, 2008
Hi , I have an Xml file which conatins certain rules for including in build. For Eg <FxCopRules> <Include category="Errors"> <Rule>Microsoft.Design#CA1012</Rule> <Rule>Microsoft.Design#CA1040</Rule> <Rule>Microsoft.Design#CA1011</Rule> <Rule>Microsoft.Design#CA1009</Rule> <Rule>Microsoft.Design#CA1050</Rule> </Include> </FxCopRules> How to make sure this can be incorporated in TFS build.Such that this rule will apply to all projects