ProgressText of custom action

Jan 25, 2016 at 9:18 AM
I'm using the custom action to run the installed app at the end:
new ManagedAction("LaunchServer", Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed)

    public class CustomActions
    {
        [CustomAction]
        public static ActionResult LaunchServer(Session session)
        {
            Process.Start(session["SERVERDIR"] + @"\Server.exe");
            return ActionResult.Success;
        }
    }
I wonder how to set up the text which is shown in the progress bar when this custom action is being executed, in Wix it normally achieved by:
<UI>
  <ProgressText Action="LaunchServer">Running Server... (this may take a few minutes).</ProgressText>
</UI>
However, I can't find any property/method in WixSharp that allows to do that.
Any help is greatly appreciated!
Jan 26, 2016 at 4:49 AM
For this you will need to use fully custom UI. One of the options is to use "External UI" you will find the sample in the downloadable package.

However I would rather go with the Managed Setup UI. The easiest way to do this is to create the VS project from the "WixSharp - Custom UI" template. Then changing the progress message is practically a single-line modification.
Jan 26, 2016 at 6:40 AM
Thanks for reply.
What about injecting the XML in the resulting wix?
new ManagedAction(new Id("LaunchServer"), "LaunchServer", Return.check, When.After, Step.InstallFinalize, Condition.NOT_Installed)
static void project_WixSourceGenerated(XDocument document)
        {
            XNamespace wi = "http://schemas.microsoft.com/wix/2006/wi";
            var uiElement = document.Descendants(wi+"UI").FirstOrDefault();
            if (uiElement == null) return;
            var launchOnExitProgressText = new XElement("ProgressText", new XAttribute("Action", "LaunchServer"), "Running Server...");
            uiElement.Add(launchOnExitProgressText);
        }
I tried it, but it does not seem to work, I am not sure why...
Jan 26, 2016 at 12:08 PM
If you want to rely on the native MSI UI then indeed you need to use injection. The sample below shows the technique. It works just fine:
//css_dir ..\..\;
//css_ref System.Core.dll;
//css_ref Wix_bin\SDK\Microsoft.Deployment.WindowsInstaller.dll;
using System;
using System.Linq;
using System.Xml.Linq;
using System.Xml;
using System.Windows.Forms;
using Microsoft.Deployment.WindowsInstaller;
using WixSharp;

class Script
{
    static public void Main(string[] args)
    {
        var project = 
            new Project("CustomActionTest",
                new ManagedAction(new Id("MyAction"), 
                                  "MyAction", 
                                  Return.check, 
                                  When.After, 
                                  Step.InstallInitialize, 
                                  Condition.NOT_Installed));

        project.WixSourceGenerated += project_WixSourceGenerated;
        project.BuildMsiCmd();
    }

    static void project_WixSourceGenerated(XDocument document)
    {
        document.FindSingle("Product")
                .Add(new XElement("UI",
                         new XElement("ProgressText", "Running Server...").AddAttributes("Action=MyAction")));
    }
}

public class CustomActions
{
    [CustomAction]
    public static ActionResult MyAction(Session session)
    {
        MessageBox.Show("Hello World!");
        session.Log("Begin MyAction Hello World");

        return ActionResult.Success;
    }
}