views:

227

answers:

1

We are trying to setup stylecop for a team development environment. So far what we have done is:

  • Checked the files into source control
  • Create an environment variable on every machine that points to that location (each dev has source checked out to a different location, this solves that)
  • Add the tag to the project as follows:

This works great, but VS complains that the file is unsafe, and I know to fix that we have to mark is safe in the registry. We wanted to create a .reg file to import this setting and make it easier for everyone. Can we use that environment variable in the path? I have tried the snippet below, but that doesn't seem to work. Is the syntax for an environment variable different?

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\MSBuild\SafeImports]
"StyleCop.4.3"="%StyleCopLocation%\\Microsoft.StyleCop.Targets"
A: 

Why you need to host that Targets file in a global place? Everyone can install a copy of StyleCop.

If you in fact plan to share StyleCop settings, please configure the projects to use a project locally setting file (*.SourceAnalysis). You can check in this file along with your projects, and then everyone is in sync.

Lex Li
But then every project will need to be configured to our rules instead of a global one. Plus the global helps with ccnet builds if you have a better way I'm all ears.
Joe
I am not familiar with CCNET, but why we could not make it work with project local settings? Isn't that a "bug"?
Lex Li
Provided that Stylecop is set up to inherit from the parent folder, you can place your rules in the root folder of the repository. Thus it will affect all projects. And for the individual projects additional rules can be enabled/disabled as needed (for example, testing projects having naming rules changed)
Agent_9191
I agree with Agent_9191. And you don't really need the environment variable - we put relative path to StyleCop " <Import Project="..\lib\Microsoft StyleCop\Microsoft.StyleCop.Targets" />" in our project files
Igor Brejc