Wix,在 ProgressDlg 中显示自定义状态消息

Wix, show custom status message in ProgressDlg

我正在尝试在默认 wix 的 ProgressDlg 中显示自定义状态消息,遵循此答案:

WiX: dynamically changing the status text during CustomAction

到目前为止,我在自定义操作中得到了这段代码:

public class CustomActions
    {
        [CustomAction]
        public static ActionResult CustomAction1(Session session)
        {
            Debugger.Launch();
            session.Log("Begin CustomAction1");
            MessageTest(session);
            return ActionResult.Success;
        }


        private static void MessageTest(Session session)
        {
            for (int i = 0; i < 10; i++)
            {
                using (Record r = new Record(0))
                {
                    r.SetString(0, $"Hello worls {i}");
                    session.Message(InstallMessage.ActionData, r);
                }
                Thread.Sleep(1000);
            }
        }
    }

然后,在Product.wxs中有如下xml片段:

<Binary Id="CuCustomInstallActionsBinary" SourceFile="$(var.ConsoleApplication1_TargetDir)CustomAction1.CA.dll" />
<CustomAction Id="CuCustomActionOnAfterInstall" BinaryKey="CuCustomInstallActionsBinary" DllEntry="CustomAction1" Execute="deferred" HideTarget="no" Return="check" Impersonate="no" />

    <InstallExecuteSequence>
      <Custom Action="CuCustomActionOnAfterInstall" Before="InstallFinalize"><![CDATA[(NOT Installed) AND (NOT REMOVE)]]></Custom>
    </InstallExecuteSequence>

但是 UI 中没有显示任何内容。自定义操作运行时,状态消息保持为空。

还有什么需要做的吗?也许订阅 <Subscribe Event="ActionData" Attribute="Text" /> 我必须为此实现自己的自定义 ProgressDlg 吗?

@jbudreau 提示后我找到了答案。 Record 实例必须有 3 个字段,它与 ActionText MSI table 中的列数相同。第一个字段必须设置为自定义操作名称,第二个是要显示的 UI 消息,第三个是模板值,在我的例子中没有使用。此外,对 session.Message() 的调用必须包含参数 InstallMessage.ActionStart。所以,最终的代码是:

public void UpdateStatus(string message)
{
   using (Record r = new Record(3))
   {
     r.SetString(1, "CuCustomActionOnAfterInstall");
     r.SetString(2, message);
     session.Message(InstallMessage.ActionStart, r);
   }
}

我还没有测试是否有必要在 ActionText 中有一个条目,这是通过在 Product.wxs 文件中放置 Product 标签内的 ProgressText 来实现的。没有这个,生成的 MSI 文件将不包含 ActionText table

<UI>
      <ProgressText Action="CuCustomActionOnAfterInstall">Running post install configuration.</ProgressText>
</UI>