Wix,在 ProgressDlg 中显示自定义状态消息 [英] Wix, show custom status message in ProgressDlg

查看:22
本文介绍了Wix,在 ProgressDlg 中显示自定义状态消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按照以下答案在默认 wix 的 ProgressDlg 中显示自定义状态消息:

还有什么应该做的来完成这个吗?也许订阅 <Subscribe Event="ActionData" Attribute="Text"/> 我是否必须为此实现我自己的自定义 ProgressDlg?

解决方案

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

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

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

<ProgressText Action="CuCustomActionOnAfterInstall">运行安装后配置.</ProgressText>

I'm trying to show a custom status message in default wix's ProgressDlg, following this answer:

WiX: dynamically changing the status text during CustomAction

So far, I got this code in my custom action:

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

Then, in Product.wxs have the following xml fragment:

<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>

But nothing is been shown in UI. The status message remains empty while the custom action runs.

Is there anything else that should be done to acomplish this? Maybe suscribing to <Subscribe Event="ActionData" Attribute="Text" /> Do I have to implement my own custom ProgressDlg for this?

解决方案

I found the answer after @jbudreau tips. The Record instance must have 3 fields, it's the same number of columns in ActionText MSI table. The first field must be set to custom action name, second is the UI message to show, and the third is the template value, not used in my case. Also, call to session.Message() must include parameter InstallMessage.ActionStart. So, the final code is:

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

I haven't tested if it's necessary to have an entry in ActionText, what is accomplished by placing in Product.wxs file a ProgressText inside Product tag. Without this, the resulting MSI file won't contain the ActionText table

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

这篇关于Wix,在 ProgressDlg 中显示自定义状态消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆