Inserting Custom Action between Dialogs (InstallUISequence) in WiX

Marlos picture Marlos · May 2, 2013 · Viewed 13k times · Source

I have two custom dialog boxes (plus the required ones ExitDlg, FatalErrorDlg, etc.), the first one sets a property using an Edit control and the second one shows this property using a Text control. Here is the meaningful code:

<Dialog Id="DialogA" ...>
  <Control Id="ControlEdit" Type="Edit" Property="MY_PROPERTY" .../>
  <Control Id="ControlNext" Type="PushButton" ...>
    <Publish Event="EndDialog" Value="Return" /></Control>
</Dialog>

And then the second dialog:

<Dialog Id="DialogB" ...>
  <Control Id="ControlText" Type="Text" Text="[MY_PROPERTY]" .../>
  <Control Id="ControlBack" Type="PushButton" ...>
    <Publish Event="EndDialog" Value="Return" /></Control>
  <Control Id="ControlNext" Type="PushButton" ...>
    <Publish Event="EndDialog" Value="Return" /></Control>
</Dialog>

And the action sequence:

<InstallUISequence>
   <Show Dialog="DialogA" Before="MyCustomAction" />
   <Custom Action="MyCustomAction" Before="DialogB" />
   <Show Dialog="DialogB" Before="ExecuteAction" />
</InstallUISequence>

The custom action changes the value of MY_PROPERTY. My problem is how to make the Back button in DialogBget back to DialogA. Using NewDialog is simple, but then I can't get the custom action to be executed between the dialogs, or can I?


edit - 2013-05-02

After the answer from @caveman_dick, I tried to change the DialogA almost like he said, but instead of using EndDialog, I changed to Action="NewDialog" Value="DialogB". But now the Custom Action isn't being called. If I remove the Publish event to go to next dialog, then the CA is called. If I leave as @caveman_dick said, I can't get back to DialogA from DialogB.


edit - 2013-05-02

After searching in book WiX 3.6: A Developer's Guide to Windows Installer XML, I found the following: "if you have more than one Publish event, they must have conditional statements as their inner text. Otherwise, all of the events simply won't be published."

So the answer from @caveman_dick is correct, except that you need to change to the following:

<Publish ...>1</Publish>

Answer

caveman_dick picture caveman_dick · May 2, 2013

Rather than scheduling the custom action in the InstallUISequence you can publish it on the button click:

<Dialog Id="DialogA" ...>
   <Control Id="ControlEdit" Type="Edit" Property="MY_PROPERTY" .../>
   <Control Id="ControlNext" Type="PushButton" ...>
       <Publish Event="DoAction" Value="MyCustomAction">1</Publish>
       <Publish Event="EndDialog" Value="Return">1</Publish>
   </Control>
</Dialog>

EDIT: The Publish element's condition needs to explicitly evaluate to true to run, so add "1" as the text of the Publish elements.