Search code examples
windowswixwindows-installerwix3.11

Dynamically changing RTF content in the EndDialog after success


Thanks to this question, I was able to make a custom action that temporary update and modifies the MSI Database on the fly.

In a nutshell I am doing

[CustomAction]
public static ActionResult VerifyLog(Session session)
{
  var sRtfText = @"{\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}THIS IS NOT DEFAULT TEXT}";
  var view = session.Database.OpenView("SELECT * FROM Control WHERE 
  Dialog_='EndDlg' AND Control='Verification'");
  view.Execute();
  var record = view.Fetch();
  view.Delete(record);
  record.SetString("Text", sRtfText);
  view.InsertTemporary(record); // also tried original post's view.Modify(ViewModifyMode.InsertTemporary, record); as well

  return ActionResult.Success;
}

and my default state of the Control is following

<Dialog Id="EndDlg" Width="600" Height="400" Title="$(var.PRODUCT_NAME)">
  <Control Id="Verification" Type="ScrollableText" X="180" Y="80" Width="410" Height="280" Sunken="yes" TabSkip="no" Text="{\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}default text\line}"/>
  <!-- Buttons for Navigation... -->
</Dialog>

My CustomAction element is following.

  <CustomAction Id="CA_01_Verify"
                BinaryKey="WiXCustomAction"
                DllEntry="VerifyLog"
                Execute="immediate"
                Return="check"/>

My InstallExecuteSequence is following.

  <InstallExecuteSequence>
    <Custom Action="CA_01_Verify" Before="CostInitialize"></Custom>
  </InstallExecuteSequence>

However, upon the End Dialog is opened on exit via <Show Dialog="EndDlg" OnExit="success"/>, somehow, the updated text is gone and the control only displays the default text.

When I do check for the text column, in the custom action, I can see that it has been updated properly. (I checked ahead of modification via CA to make sure default WAS there and IS UPDATED).

Just for the sake of it I made another custom action that just checks for the Text entry in the EndDlg Verification Control and I confirmed that the Text column for Verification Control is properly updated.

If it is updated properly in the table, why is it not updated on the UI?

Just as a reference followings are the result log

Action 11:49:35: CA_01_Verify. 
Action start 11:49:35: CA_01_Verify.
MSI (s) (2C:A8) [11:49:35:044]: Invoking remote custom action. DLL: C:\WINDOWS\Installer\MSIAC6F.tmp, Entrypoint: VerifyLog
MSI (s) (2C:C8) [11:49:35:045]: Generating random cookie.
MSI (s) (2C:C8) [11:49:35:057]: Created Custom Action Server with PID 26272 (0x66A0).
MSI (s) (2C:80) [11:49:35:086]: Running as a service.
MSI (s) (2C:80) [11:49:35:089]: Hello, I'm your 32bit Impersonated custom action server.
SFXCA: Extracting custom action to temporary directory: C:\WINDOWS\Installer\MSIAC6F.tmp-\
SFXCA: Binding to CLR version v4.0.30319
Calling custom action WiXCustomAction!WiXCustomAction.CustomActions.VerifyLog
VerifyLog started
MSI (s) (2C!90) [11:49:35:230]: PROPERTY CHANGE: Adding VerifyLog property. Its value is 'Started'.
Opening the view from control table
view.Execute()
view.Fetch()
Current Text Column: {\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}default text\line}
view.Delete()
setting the text with rtf content : {\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}THIS IS NOT DEFAULT TEXT}
Current Text Column Before set string : {\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}default text\line}
Current Text Column After set string : {\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}THIS IS NOT DEFAULT TEXT}
view.Modify
Current Text Column Before Insert: {\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}THIS IS NOT DEFAULT TEXT}
Current Text Column After Insert: {\rtf1\ansi\deff0{\colortbl;\red0\green0\blue0;\red255\green0\blue0;}THIS IS NOT DEFAULT TEXT}
Success

Solution

  • There is a mock-up example checked into github.com here: https://github.com/glytzhkof/WiXViewLogExperiment

    This sample features a spawned dialog from a custom setup ExitDialog (called MyExitDialog) which shows the content of an RTF file. Please replace the "TestFile.rtf" on disk with your own RTF file and just compile and run the resulting MSI to check how this works.

    Screenshot


    Open MSI Log: I have another sample here for how to open the MSI log from the last MSI dialog: https://github.com/glytzhkof/WiXOpenLogFile (made first without understanding requirements properly - but always wanted this feature - it is not finished, but a functional demo).

    (there is a feature to hide the open log checkbox if there is no MSI log created - use the Enable Global MSI Logging.reg file to enable MSI logging for all MSI operations. The log shows up with a random name in the TEMP folder.)


    Link Section:

    WiX GUI is both the embedded MSI GUI inside MSI files, but also the Burn setup.exe launcher GUI that can be created with many different and modern technologies. So MSI GUI versus setup.exe GUI.

    Some selected links on WiX GUI: