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

Mar*_*los 5 custom-action wix

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

显示所有其他文本(例如文件副本),正确填充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>
Run Code Online (Sandbox Code Playgroud)

UI库:

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

  ...
Run Code Online (Sandbox Code Playgroud)

C#自定义动作库:

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;
  }
}
Run Code Online (Sandbox Code Playgroud)

Rol*_*olo 3

The problem is that you are using "ActionData" but you are not sending a message to the UI with this action data from your custom action.

You must add something like:

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;
  }
}
Run Code Online (Sandbox Code Playgroud)

You can send as many messages as you want from your CA.

If you were using "ActionText" instead it will work but will display the custom action name without additional/custom information.

You will find additional information here:

WiX: dynamically changing the status text during CustomAction