Wednesday, December 3, 2008

Macros in Hint Paths

I am working on building a binary publishing system at my work.  While implementing it I ran into what I thought might be a snag.  I wanted to switch a project from having a project reference to another project to be a binary reference.  But I wanted that binary reference to change depending on which configuration (Debug/Release) I was in.  This seems like a pretty standard thing to do.  You want the binary reference to come from bin/release in release mode and bin/debug in debug mode.

The VS GUI gives no indication that this is possible, you pick a file location for a dll and you are done.  Luckily VS is smart enough to interpolate macros in the hint path for the reference.  So you can make the hint path be some thing like ../bin/$(Configuration)/foo.dll and you will get the behavior you want.  But you need to crack open the .csproj file in a text editor to do this.

One the one hand it is really nice that VS is smart enough to enable this scenario.  On the other hand it would be nice if there was a way to do this via the GUI.

0 comments: