Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting Custom Action between Dialogs (InstallUISequence) in WiX

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>
like image 725
Marlos Avatar asked May 02 '13 11:05

Marlos


People also ask

How do I create a custom action on WiX?

You need to create a new C# Custom Action Project for WiX v3 in your solution. Change the function name to a name that fits your function. After that right click on the References Folder on your WiX setup project and choose Add Reference... . Click the tab Projects and choose your custom action Project.

How do I add custom dialogues to WiX installers?

You can add custom dialogs to the UI sequence in a built-in WixUI dialog set. To do so, you must define a <UI/> element for your new dialog. Then, you must copy the contents of the <Fragment/> that includes the definition of the dialog set that you want to customize from the WiX source code to your project.


1 Answers

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.

like image 74
caveman_dick Avatar answered Oct 20 '22 05:10

caveman_dick