WiX: dynamically changing the status text during CustomAction

╄→尐↘猪︶ㄣ 提交于 2019-12-28 18:04:04

问题


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.


回答1:


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.




回答2:


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.




回答3:


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, ""));
      };


来源:https://stackoverflow.com/questions/11722541/wix-dynamically-changing-the-status-text-during-customaction

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!