Defining common fxcop ruleset for all projects/solutions/configurations


User wants to configure a common set of fxcop rules and use them for all projects/solutions. Does he need to configure the common set for every new project/solution/configuration?


No. User need to override the "CodeAnalysisRules" property to include the common rules he wants to use across the projects/solutions/configurations. He can define the property in the tfsbuild.proj file. Defining the property in this file will override the project specific value of this property (defined in *.csproj).


For more details about Static Analysis in Team Build, refer this post.


Disclaimer: I have not tried this fix myself but it should work.


Comments (6)

  1. Jim Lesch says:

    Manish, I am using the release bits of Team Suite and I can’t find any global tfsbuild.proj file that I can edit which would affect all team projects I work on. Also, the tfsbuild.proj file that I do find belongs to a team project and it only contains an option to override the execution of code analysis (Default/Always/Never) and does not appear allow me to specify the set of rules I want to use. I have tried to manually overwrite the rule sets in the <CodeAnalysis> element of our .vbproj files, but this corrupts the project. Is it possible to do what I’m trying to do?

  2. ManishAgarwal says:


    1) There is no global tfsbuild.proj file. This file represent the build configuration for only one team project. If you want to share the settings for multiple team projects, you have to do the customization seperately for the build type (tfsbuild.proj) for each team project. We might allow working across different team projects in next version but I can not comment on it now.

    2)CodeAnalysisRules property is defined in the .xxproj files for the solutions. Since this file was created automatically by the VS, your manualy modification can create problems. Moreover it is not a good idea to make changes in this file because any other user who is not using teambuild will also get your customization. If you redefine this property in the tfsbuild.proj file, then msbuild will ignore the value set in .xxproj file and will use the one specified by you (in tfsbuild).

  3. Jim Lesch says:

    Thanks very much for your answers Manish. I hope you don’t mind if I ask one more:

    1. One of my goals is to define a subset of FXCop rules including some custom rules that would be the set of rules that a set of code must pass before being checked in and/or deployed to production. What approach do you suggest to accomplish this goal?

    Thanks again,


  4. ManishAgarwal says:

    Jim, I am not very clear about your query. It looks like you want to set/invoke some set of custom fxcop rules before checkin (files).

    Two points to note

    1) If you want to selectively run rules for some projects and avoid others, you have to make changes in the corresponding csproj files. Rules in tfsbuild will be applicable to all slns and projects. An alternative is to use "Conditional definition of properties" but it is not scalable approach.

    2) Team Foundation already has concept of "checkin policies" in version control. You might want to set your own fxcop rule.

    Moreover this is not related to build process in general.

  5. Sharmila Prasad says:

    I am using Visual Studio Team Suite and I want to anlyse Fxcop vs. Static Code Analysis. When I enable Code Analysis in Visual Studio project and make changes to the rules, I don’t see the changes taking effect when I run the code analysis!!! i.e I don’t see the errors that I ahve enabled and changed from warning status and also I have introduced an change in my code to reveal this error.

Skip to main content