Many times, I have been fooled as Andrew has been. In fact, the same error has been reported more than twice from different channels where users had no idea where they were wrong.
The properties in the Code Analysis tab of the project properties is as shown. As a new user, I won't pay much attention to the two dropdowns on top which are anyway set to Active. But when I happily choose my rules and save the project, I build it to see that the rules are being applied fine. Then I proceed to make a build type to build the solution. But, the code analysis rules are no longer honored!! Why would that be? That is because the default configurations are Release, Any CPU for build type creation while default configurations are Debug, Any CPU for setting code analysis rules. Hmm... so whose fault is it? Project properties or Team Build or worse, the user 😉 ?
Team Build chooses a default value of Release based on a very logical assumption that when daily builds are created, people usually want usable, crisp and testable builds without loads of debug info, which means the release builds are the logical defaults. Project properties will have an equally logical choice of default value, Debug where projects are usually built in this mode in VS. But the hapless user also is not in a happy position when he needs to set code analysis rules after paying careful attention to the 2 drop downs and remembering the effect of those long after. Having a check box per configuration with all configs checked cannot be feasible since custom configurations are going to explode the combinations possible and make no space available for that many chcek boxes. Choosing All Platforms and All Flavors as a default option may not make much sense in a Code Analysis setting itself and obviously the Build settings would be worse. Well...
I can't think of any creative solution to this. Perhaps you can?