Disable specific Code Analysis rules for a Team Build

After searching a bit, I found a way to disable specific Code Analysis rules for a team build. Or at least I thought so... The RunCodeAnalysis tag in my build.proj file is set to 'Always' to override the individual project settings, and I added the 'CodeAnalysisRules' tag to exclude some rules as a test. (See below for a part of the build.proj file.) I ran a few builds, but the tag doesn't seem to do what is supposed to. But when you use that tag in a project file, Visual Studio does recognize it as a valid tag... 

Unfortunately the build seems to execute all the rules, including the ones I tried to exclude by putting them in the CodeAnalysisRules tag with a '-' before them. I'm trying to find out if it is possible to exclude specific rules through the build file. I know it is possible to do so by putting the stuff in the CodeAnalysisRules tag my project file, but with a solution of 98 projects, this is not realy an option. ;)
I'll keep you posted. And, as always, if you have any idea: drop me a line.

Snippet build.proj file:

    <RunCodeAnalysis>Always</RunCodeAnalysis>
    <CodeAnalysisRules>-Microsoft.Globalization#CA1301;-Microsoft.Globalization#CA1302;</CodeAnalysisRules>


Edit 1
I tried Jan's suggestion (see the comments) and moved the '-' sign from in front if the Microsoft name to behind the #. This did not result in any rules being ignored either. So, unfortunately, our build still checks all rules, including the ones we don't want it to check.
By the way, I know I can set Code Analysis rules as a check-in policy, and migrate those settings to the solution, but at this point it's not possible to check out al of the 98 projects: several colleagues have projects checked out, and we're working towards a deadline, so ...

Edit 2
I also tried the suggestion David Kean posted over here, but to no avail. This might work for a project, but does not when entered in a TFS Build project. It looks like I will have to change the code analysis for all projects separately, in stead of being able to set it once for all projects in a build/solution. :(

Published Fri, Aug 31 2007 9:15 AM by Rick van den Bosch
Filed under: , ,

Comments

# re: Disable specific Code Analysis rules for a Team Build

Have you tried setting the - character after the # mark? The value after that character is the unique ID for the rule.

Friday, August 31, 2007 11:05 AM by Jan Schreuder

# re: Disable specific Code Analysis rules for a Team Build

Hi Jan,

Haven't tried that, but I'll do so now. Although the way the tag is filled now is a copy of how Visual Studio places the rules inside the tag of a project file. You would expect that to be the way to go ;)

I'll keep you posted.

Friday, August 31, 2007 11:15 AM by Rick van den Bosch

# Disable specific Code Analysis rules for a Team Build - Gump&#39;s blog

Pingback from  Disable specific Code Analysis rules for a Team Build - Gump&#39;s blog

# re: Disable specific Code Analysis rules for a Team Build

The <CodeAnalysisRules> element is a part of <PropertyGroup> element in your case, which means that every tag (no matter what name it has) is valid, and it means definition of a property and assigning a value.

I'd suggest you put an edit on this post, to point to your other post where you described how to make this work:

bloggingabout.tellus.nl/.../howto-disable-specific-code-analysis-rules-for-a-team-build.aspx

Thursday, November 01, 2007 9:55 AM by Hamed Iravanchi

Leave a Comment

(required) 
(required) 
(optional)
(required) 
Please add 4 and 4 and type the answer here: