0

Specifically, in my WIX deployment project, I am trying to set TARGETDIR to [ProgramFilesFolder][Manufacturer] so that when my custom modified version of WixUI_InstallDir opens InstallDirDlg it defaults to that path rather than to the drive root.

Based on answers I found to questions about setting TARGETDIR, inserting actions between dialogs, and various data in the documentation, I've been trying various forms of a custom action like this:

<CustomAction Id="SetTARGETDIR" Property="TARGETDIR" Value="[ProgramFilesFolder][Manufacturer]" Execute="immediate" />

I've also tried Property="WIXUI_INSTALLDIR", Execute="firstSequence", and hard-coding Value.

I've tried invoking this with InstallExecuteSequence:

<InstallExecuteSequence>
  <Custom Action="SetTARGETDIR" After="FindRelatedProducts"></Custom>
</InstallExecuteSequence>

And of course, I've tried to insert before or after many different events. (One annoying obstacle is that I would expect Before="InstallDirDlg" to be the best place to insert the action, but I get a compile error when I try to use any of the dialogs as events.)

I've also tried to publish the action within the UI fragment at the time that the InstallDirDlg is invoked:

<Publish Dialog="WelcomeDlg" Control="Next" Event="DoAction" Value="SetTARGETDIR">NOT Installed</Publish>

A few things I have tried throw an error, but most of the time, the problem is just that TARGETDIR has not changed. The default install path is still the drive root. My best guess is that there is something about the use of this WixUI that fundamentally changes how I should expect a custom action to fire. But I can't seem to find any clue why this is so.

Community
  • 1
  • 1
Mark Bailey
  • 1,091
  • 10
  • 25

1 Answers1

1

If you use the WixUI_InstallDir template, there is one specific Property used to define the installation directory. This property is called WIXUI_INSTALLDIR. Take a look at the following code snippet to see how it works:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder" Name="PFiles">
    <Directory Id="TESTFILEPRODUCTDIR" Name="Test File">
      ...
    </Directory>
   </Directory>
</Directory>
...
<Property Id="WIXUI_INSTALLDIR" Value="TESTFILEPRODUCTDIR" />
<UIRef Id="WixUI_InstallDir" />

This example is taken directly from the documentation found here: WixUI_InstallDir Dialog Set.

If I have understood your example correctly, then you would include another subdirectory with the manufacturer name. Be aware that it is not possible to use properties as directory names. You can use $(var.variables) or !(loc.localizationVariables) instead. I would advise the use of localization variables. E.g.:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder" Name="PFiles">
    <Directory Id="ManufacturerDir" Name="!(loc.manufacturer)">
      <Directory Id="TESTFILEPRODUCTDIR" Name="Test File">
      ...
      </Directory>
    <Directory>
   </Directory>
</Directory>

On another note: If you want to execute a custom action before the dialogs are shown, you have to schedule it in the InstallUISequence. See the Standard Actions Reference to understand what they do and then have a look at the installer log. You'll see when the standard actions take place and you can then accordingly schedule your custom action.

For example:

<InstallUISequence>
  <Custom Action="MyCA" Before="AppSearch" />
</InstallUISequence>

ensures that the MyCA custom action gets executed before the first standard action takes place.

BdN3504
  • 1,693
  • 21
  • 29
  • 1
    Actually, properties can be used as directory names using linker binding, like this: – Mark Bailey Sep 19 '13 at 14:29
  • 1
    This answer basically includes the core concepts that answer my question. The other important point I want to add is that TARGETDIR is not really a normal variable. It's a special case (see http://stackoverflow.com/questions/1641094/in-wix-files-what-does-name-sourcedir-refer-to). So it was probably somewhat Quixotic to try to accomplish this by setting it with a custom action. – Mark Bailey Sep 19 '13 at 16:57