views:

273

answers:

1

Hi,

I need to define a custom build rule for files in my projects. However the rule may be different for different solutions (more percisely, for the same solution in a parallel dev branch).

I have two questions:

  1. Can a .rules file be specified in a location relative to the solution? That way I'd be able to create rules per development branch.

  2. MSDN says that the custom rule is inheritable similarly to the properties (vsprops). How can that be achieved? Where do I specify the inheritance?

Thanks,

Gil Moses.

A: 

.vcproj file will contain the following clause:

 <ToolFiles>
    <ToolFile
      RelativePath="..\my.rules"
    />
 </ToolFiles>

You can use $(SolutionDir) to customize placement of the .rules file, like this:

 <ToolFiles>
    <ToolFile
      RelativePath="$(SolutionDir)..\..\..\my.rules"
    />
 </ToolFiles>
Alex Cohn
This is great! I will use it in this fashion.What about my #2 question?Thanks,Gil.
Gil
@Alex, have you been able to get this to work in Visual Studio 2005? When I begin the RelativePath property with $(SolutionDir), Visual Studio seems to still be treating it relative to the project file
Nick Meyer
Sorry Nick, never tried it for 2005. I am not sure the problem is relevant for Gil: he wants separate rules in different branches, and probably the branches contain .vcproj files and .sln files.
Alex Cohn