Is there any way to activate code analysis feature of Visual Studio 2012 by default for every project? And, if possible to set the rules to ‘Microsoft All Rules’ by default.
Every time I create a new project I have to manually activate “Enable Code Analysis on Build” at the project properties and have to set the rules to all rules.
Sometimes I forget to do that and have to fix more issues. I could have prevented if it was activated by default.
You could edit the default project template that Visual Studio uses when you create a new project to add a common import, the problem is when it comes to prototyping do you want those settings on.
I tend to ensure that every project imports a common set of msbuild properties and item groups. This will not work by default as you would have to edit each proj file and add the import, but the advantage is that with just one line you could put so much more than just Code Analysis settings in this imported proj file, for instance, StyleCop settings, the dictionary culture that is used by Code Analysis, your own rule set file, a common AssemblyInfo.cs, snk files, etc
I tend to place the following line just before the last line in my .csproj
And then in the imported file something like this. This way ever project has the same settings.