We have a number of large solutions and have a number of ruleset files based on the different project types. For example we have:
A Sharepoint Rulesset containing:
A test project ruleset
A standard ruleset
I'd love it if Code Analysis were able to automatically select the right set based on the project type.
I haven't found the ideal way to do this. Things I'll consider:
What we're currently doing:
I'd love to hear ideas for a better solution...
I found a solution that works for most project types. Many of the default Msbuild targets provided by Microsoft include an option to load BeforeTargets and Aftertargets by placing the targets in question in a specific folder in the Msbuild folder structure.
I put a targets file into these folders (naming based on the way the project type expects them, these tend to differ from project type to project type) where I specify the default CodeAnalaysis.rules file. The project can still override these, but if it doesn't the default is used.
Sharepoint for example looks for this file:
$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\SharePointTools\Custom.After.Microsoft.VisualStudio.SharePoint.targets
These references are stored in msbuild properties such as $(CustomAfterSharePointTargets)
which you can extend or override if wanted.
My solution is built upon this feature and this feature.
I put in a request to standardize this more in Visual Studio 11. Please vote for it.