wix - ProgressText 不适用于 WiX 中的自定义操作

标签 wix custom-action

我想在安装过程中显示我的自定义操作的进度文本。我在 WiX Progress Text for a Custom Action 中实现了代码但它不起作用。

显示所有其他文本(例如文件副本),正确填充 ActionText 表并且 ActionText.Action 匹配 CustomAction.Actuib 值。有谁知道出了什么问题?这是代码:

WiX 主要项目:

<Product>
  <CustomAction Id="MyCA" BinaryKey="MyCALib"
                DllEntry="MyCAMethod" Execute="deferred"
                Return="check" />
  <InstallExecuteSequence>
     <Custom Action="MyCA" Before="InstallFinalize" />
  </InstallExecuteSequence>
  <UI>
    <UIRef Id="MyUILibraryUI" />
  </UI>
</Product>

用户界面库:

<Wix ...><Fragment>

  <UI Id="MyUILibraryUI">

    <ProgressText Action="MyCA">Executing my funny CA...
    </ProgressText>

    ...

    <Dialog Id="Dialog_Progress" ...>
      <Control Id="Ctrl_ActionText"
               Type="Text" ...>
        <Subscribe Event="ActionData" Attribute="Text" />
      </Control>

  ...

C# 自定义 Action 库:

public class MyCALib
{
  [CustomAction]
  public static ActionResult MyCAMethod(Session session)
  {
      System.Threading.Thread.Sleep(10000); // to show text
      // do something
      System.Threading.Thread.Sleep(10000); // to show text

      return ActionResult.Success;
  }
}

最佳答案

问题是您正在使用“ActionData”,但您没有使用来自自定义操作的此操作数据向 UI 发送消息。

您必须添加如下内容:

public class MyCALib
{
  [CustomAction]
  public static ActionResult MyCAMethod(Session session)
  {
      using (Record record = new Record(0))
      {
          record.SetString(0, "Starting MyCAMethod");
          Session.Message(InstallMessage.ActionData, record);
      }

      System.Threading.Thread.Sleep(10000); // to show text
      // do something
      System.Threading.Thread.Sleep(10000); // to show text

      return ActionResult.Success;
  }
}

您可以根据需要从 CA 发送任意数量的消息。

如果您使用的是“ActionText”,它将起作用,但会显示自定义操作名称,而无需附加/自定义信息。

您将在此处找到更多信息:

WiX: dynamically changing the status text during CustomAction

关于wix - ProgressText 不适用于 WiX 中的自定义操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17221402/

相关文章:

dialog - XP 中的开始和最终对话框不显示位图

Wix:动态添加功能

unicode - 无法使用自定义操作将 MSI 安装到用户名中包含非 ascii 字符的非管理员

wix - 如果 CustomAction 出现错误,如何强制卸载 WiX

wix - MSI 安装程序扩展如何定位另一个应用程序的安装目录?

powershell - 我们如何从失败的.msi安装中上传日志文件(使用WiX创建)

属性值的 WiX 自定义操作条件

.net - Windows Installer 进度条消息占位符 "[1]"未被替换

wix - 如何执行带有依赖项的 WiX 自定义操作 C++ DLL 文件?

c# - 从 CA 到 Wix 的 Wix 自定义操作设置值