Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ProgressText not working for custom action in WiX

I want to show the progress text of my custom action during installation. I implemented the code as in WiX Progress Text for a Custom Action but it doesn't work.

All other text (file copy, for example) is shown, the ActionText table is correctly populated and the ActionText.Action matches CustomAction.Actuib values. Does anyone know what is going wrong? Here is the code:

Main WiX project:

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

UI library:

<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# custom action library:

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;
  }
}
like image 413
Marlos Avatar asked Jun 20 '13 18:06

Marlos


1 Answers

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

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

like image 106
Rolo Avatar answered Sep 23 '22 13:09

Rolo