2
votes

I'm trying to build a multi-instance installer that creates a directory with an appropriate name underneath the INSTALLDIR directory:

<Directory Id="INSTALLDIR" Name="My Product">
    <Directory Id="SERVERDIR" Name="Server" />
</Directory>
<SetDirectory Id="SERVERDIR" Value="[INSTALLDIR]Server ([INSTANCEID])">NOT (INSTANCEID="DEFAULT")</SetDirectory>

I'd hoped at least the INSTALLDIR property would have been passed in at the start of the InstallExecute sequence even if most other directories hadn't been resolved from it yet by CostFinalize. Is there any way to find the user specified installation directory before CostFinalize so I can correctly set the SERVERDIR path?


Update 1: I'm guessing in most cases INSTALLDIR itself gets resolved by CostFinalize unless it's set on the command line (hence why it's blank to me). I could have my own property that defaults to where I expect INSTALLDIR to be unless it's been set by the user. Need to figure out how the UI passes it in - hoping it just passes INSTALLDIR normally.


Update 2: The UI passes across INSTALLDIR. But it also passes across all other resolved directories including the directories beneath SERVERDIR. I need to run SetDirectory action in both sequences and come up with a default INSTALLDIR property myself. I should also buy myself a rubber duck.

1

1 Answers

3
votes

SetDirectory can use properties in formatted strings, but you need to be careful as to when such properties are set. In a normal UI install:

  • InstallUISequence runs
    • CostFinalize resolves and sets the directory properties
    • Dialogs are shown (INSTALLDIR has already been set by CostFinalize)
  • InstallExecute runs
    • Install directory properties are pushed into the sequence

The SetDirectory element runs before CostFinalize, and paths it uses must be full paths. To base the SERVERDIR property off the INSTALLDIR property as above make sure a default INSTALLDIR has been set that represents how the resolve would normally occur:

<SetDirectory Action="SetInstallDir" Id="INSTALLDIR" Value="[$(var.Variables_ProgramFilesFolderId)]$(var.Variables_ManufacturerDir)\$(var.Variables_ProductNameShort)\">INSTALLDIR=""</SetDirectory>
<SetDirectory Action="SetServerInstallDir" Id="SERVERINSTALLDIR" Value="[INSTALLDIR]Server ([INSTANCEID])\">NOT (INSTANCEID="DEFAULT")</SetDirectory>