Wednesday, February 18, 2009

Installing Directory Structres in WIX

I've been doing some WIX work lately and so far I have been pretty happy with it so far.  But one thing has been bugging me.  I want to install a directory structure of content files (in this case our help file collection) but I don't want to have a hard coded list of files.

I get that its not a best practice to do it this way.  But I don't really care about patching or upgrading.  Our company has made a business decision that we only do full installs, we don't support patching or upgrading, only uninstall/re-install. I just want to put one statement into my install and have a whole directory show up in my install.  Should be easy but its not.

So the only thing to do is to test out the extensibility model of WIX.  Turns out to be pretty easy to extend.  3 classes, 110 lines of code, and 1 XSD file was all that was needed.

The full project is here.  Just compile it and then reference the dll in your install project.  Then just add a FileGroup element into your XML. Then specify four attributes:
  • Source : The path to the directory to copy.
  • DirectoryRoot: The WIX directory ID that the root of the copy should be installed to.
  • DirectoryName: The the directory should be called on the target machine.
  • ComponentGroupID: This is the ID for the final ComponentGroup that is created, you can refrence this in your features.
Hopefully its pretty easy to use.  One improvement I think I might make soon is to add an excluding rule to it.  Should be pretty easy to do if though.


0 comments: