Consistent rules across multiple projects in VS2K5 solution  
Author Message
devlinse





PostPosted: Visual Studio Code Analysis and Code Metrics, Consistent rules across multiple projects in VS2K5 solution Top

Hi there,

This might seem like a very simple question and I apologize if I've missed it, but how do you apply the same Code Analysis template across multiple projects in the same solution

Sure I can go to each project, and set the properties manually, but is there a way to set it at the solution level For example I wish to disable warnings associated with strong names across a solution with about 20 projects in it. Manually this is quite time consuming.

Cheers



Visual Studio Team System27  
 
 
Jeffrey van Gogh - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, Consistent rules across multiple projects in VS2K5 solution Top

Hi Devlinse,

if you're using Visual Studio Team Foundation Server, you can create a "Code Analysis Policy" on your team project, set your rule settings there and subsequently migrate these settings to all your projects by right-clicking on the solution object in the solution explorer and selecting "Migrate Code Analysis Policy".

If you're not using Visual Studio Team Foundation Server, there is no build-in support for applying rule settings to multiple projects. One thing you can do is manually modify the msbuild projects to all include a shared project/target file that contains the rule settings. See the MSBuild wiki for more details on this: http://channel9.msdn.com/wiki/default.aspx/MSBuild.UseTheSameTargetInMultipleProjectFiles

Regards,

Jeffrey


 
 
David M. Kean - MSFT





PostPosted: Visual Studio Code Analysis and Code Metrics, Consistent rules across multiple projects in VS2K5 solution Top

We also just posted a blog post about Daniel Fisher who wrote a macro to do exactly this:

http://blogs.msdn.com/fxcop/archive/2006/08/11/694387.aspx

However, this is a quick fix, and the better way would be to go down the shared targets file as mentioned by Jeff.



 
 
devlinse





PostPosted: Visual Studio Code Analysis and Code Metrics, Consistent rules across multiple projects in VS2K5 solution Top

Hi Jeffery,

Thanks for this. TFS isn't yet an approved product where I'm working (the wheels of big companies sometimes turn slowly), but it's handy to know that it's there for future reference. I'll look at your other suggestion as it's time I got to grips with MSBuild a bit more.

Regards


 
 
devlinse





PostPosted: Visual Studio Code Analysis and Code Metrics, Consistent rules across multiple projects in VS2K5 solution Top

Hi David,

For now, a quick fix is just fine but I'll be looking at the shard targets suggestion too. It's just a bit of a shame there's not way set Code Analysis options at the solution (or solution folder level).

Hopefully TFS will be approved for use soon (anything to be rid of the horror that is Clearcase...)

Regards