views:

206

answers:

2

Here's what I'm trying to do: I have two solutions - one for my main application and its associated projects and another for my database (VS .dbproj) and its associated projects. What I'd like to do is include the output from the database project (a .dbschema and some SQL scripts) in my WiX installer (which exists in the main application solution.) This involves having TFS build the DB solution immediately before the main application solution. I've got that part working properly, but I'm having trouble referencing the output of the DB solution from my installer.

I'm using relative paths to reference the DB project output in my WiX installer (e.g. <?define DBProjectOutputDir = "..\..\MyDatabaseSolution\MyDatabaseProject\sql\"?>) which works fine locally, but fails when building via TFS build. This is because TFS Build apparently changes the output dir of each project to one common location. Instead of the path to my database project being ..\..\MyDatabaseSolution\MyDatabaseProject\sql\ like it is when building locally, it gets set to something like ..\..\..\Binaries\Release\. How can I get around this and have a consistent output location to reference from my installer project? I'm using TFS 2005, VS 2008 and WiX 3.0.

A: 

If you add a reference (to your db app) into your wix project in VS then you can use the following variable rather than the relative paths, and it will point to which ever build folder is currently selected in your configuration.

$(var.MyDatabaseProject.TargetDir)

Here is a good reference

Charles Gargent
This only works if the DB project is in the same solution as the WiX project. I have two solutions with the installer project in one and the DB project in the other.
pmdarrow
A: 

After some extensive digging through the WiX mailing list, I found out that you can reference the current installer project output dir by using $(var.TargetDir). Since it's only in TFS Build that the output of all the projects get put in one directory, I was able to make a special case for the build server by looking at the ComputerName environment variable:

<?if $(env.ComputerName) = "MYBUILDSERVER"?>
  <?define DBProjectOutputDir = "$(var.TargetDir)"?>
<?else?>
  <?define DBProjectOutputDir = "..\..\MyDatabaseSolution\MyDatabaseProject\sql\"?>
<?endif?>

This way, DBProjectOutputDir always points to the right directory. It's a bit of a workaround so I'm still looking for a better approach.

pmdarrow