I’m surprised I haven’t been able to find a simple answer for this, since it seems like it would be a common thing to do.
I’m trying to set the install path based on the machine name of the server it is being installed on, as they have different folder structures.
I’m assuming I need some kind of custom action, but being brand new to WiX, I’m having a hard time figuring out where to start.
I suppose I can just make separate installers for each server (since it’s only 3), but it would probably be better practice to just have one that’s reusable.
A point in the right direction would be greatly appreciated! Thanks.
Suppose you have the following directory structure in your WiX authoring:
The
INSTALLLOCATIONfolder name should differ based on the machine name. You can author aSetDirectoryelement to set the directory path to the desired value (it is a hard code below, just to show the idea):The
SetDirectoryelement schedules the underlying custom action properly. Note the way environment variable is referenced in WiX:[%COMPUTERNAME]. If you target Windows Installer 4.0+, you can rely on the special propertyComputerName.Update: depending on the exact requirements, you can go further and experiment:
etc.