Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WiX: dynamically changing the status text during CustomAction

Tags:

wix

wix3.5

I have a pretty lengthy CustomAction in a wix installer, and I want to be able to change the 'Status: ...' text while the operation runs, to see that there is progress and update on its internal status. I know how to set the progresstext of a custom action - but what I want is to dynamically change the progress text during the run of the custom action.

like image 885
Roy Reznik Avatar asked Jul 30 '12 13:07

Roy Reznik


3 Answers

Deferred Custom Actions can call the MsiProcessMessage function. You can then use INSTALLMESSAGE_ACTIONSTART, INSTALLMESSAGE_ACTIONDATA and INSTALLMESSAGE_PROGRESS to publish messages up to the UI.

Another possibility would be to break your custom action up into smaller custom actions and use the ProgressText (ActionText table) to describe different phases of installation. ( Make each CA have a single responsibility. )

Sometimes when a CA does too much work it's hard to plan rollbacks correctly.

Obtaining Context Information for Deferred Execution Custom Actions

MsiProcessMessage function

Using C#/DTF it looks something like:

    using (Record record = new Record(0))
    {
        record.SetString(0, "foo");
        session.Message(InstallMessage.ActionData, record);
    }

The using statement disposes the record to free up the underlying MSI handles. The number of fields in the record and how you set the data is going to depend on the template defined in the ActionText table.

like image 99
Christopher Painter Avatar answered Oct 06 '22 00:10

Christopher Painter


Chris has correctly explained how to send the message to ActionData from your CA, but if you are using InstallShield, make sure you create a label on the SetupProgress dialog and subscribe the ActionData text event to it. Simply, creating an ActionText event for a label is not enough as it will only display the CA description you create in the ActionText Table.

like image 29
Greg Westerfield Jr Avatar answered Oct 06 '22 00:10

Greg Westerfield Jr


The above answer doesn't work for me. The status is never updated.

Directly calling the AddProgressInfo function works in my case.

      Action<Session, string> updateStatusMessage = (session, msg) =>
      {
            session.Message(InstallMessage.ActionStart, new Record("callAddProgressInfo", msg, ""));
      };
like image 44
Weq Avatar answered Oct 06 '22 02:10

Weq