Simplified Bootstrapper & Managed UI

Jan 26, 2016 at 1:31 PM
Hello,
I would like to use the "Simplified Bootstrapper" approach to run & install the prerequisite msi in the event it's not installed.
I reviewed the corresponding sample and added the required bits in my code - the custom action that copies the msi in the temp file and runs it and its call before LaunchConditions step.
The problem is the custom action never gets called if it's in InstallUISequence. I guess that the reason of that is my project is using the managed UI in order to insert the custom dialog.
The action is called in InstallExecuteSequence, but does not work properly.
Is where anything I can do in order to get these 2 features worked together?
Coordinator
Jan 26, 2016 at 10:55 PM
I think the best way to solve it is to use ManagedSetup events. The Load event is triggered before AppSerach action and internally Wix# runtime takes care of detecting if it is InstallUI or Install sequence. Thus it's completely transparent for the user. In the event handler itself you can do what ever you want. You can check the launch conditions or you can start another msi execution.

Have a look at this sample: https://wixsharp.codeplex.com/SourceControl/latest#src/WixSharp.Samples/Wix# Samples/Managed Setup/setup.cs
Jan 27, 2016 at 8:27 AM
Thank you for sending the prompt reply! I tried this approach:
           project.Load += project_Load;
            var msiFile = Compiler.BuildMsi(project);

        static void project_Load(SetupEventArgs e)
        {
            Func<bool> checkSoftware = () => CustomActions.SoftwareInstalled(CustomActions.RemoteConnectorGuid);
            if (e.IsInstalling)
            {
                if (checkSoftware())
                {
                    e.Result = ActionResult.Success;
                    return;
                }
                var tempMsiFilePath = Path.ChangeExtension(Path.GetTempFileName(), ".msi");
                var msiFileId = "RemoteConnector.msi".Expand();
                e.Session.SaveBinary(msiFileId, tempMsiFilePath);
                Process.Start(tempMsiFilePath).WaitForExit();
                e.Result = checkSoftware() ? ActionResult.Success : ActionResult.Failure;
            }
        }
And the project_Load handler is raised after the progress dialog of main installer shows up and when remoteconnector.msi is called, windows spits the error:
Another Installation is in Progress you must complete the installation before continuing this one
which I guess fair enough.
Any ideas on how to fix it?
Coordinator
Jan 27, 2016 at 9:48 AM
OK, I wasn't sure if it's OK to do the install before AppSearch. And after your feedback I do remember that it has to be before LaunchConditions as you referred in your original question. This means that it has to be UI sequence as other stages are too late. Thus if you stick to the simplified-botstrapper approach you will have to force user to run msi with UI.

If it's not acceptable then you will have to go with the real bootstrapper (Burn), the one that is officially integrated with WiX (samples are included). Though WiX Burn has a reported bug that prevents this butstrupper from displaying EmbeddedUI. thus you will need to use either standard or custom bootstrapper UI (WinForms and WPF samples are also included).
Jan 27, 2016 at 10:41 AM
I see, I guess the native wix UI would my choice for now, simplified bootstrapper works fine with it. Thanks again.
Coordinator
Jan 27, 2016 at 10:46 PM
OK then.

Though if you are choosing MSI native UI then you are arguably better off with the native bootstrapper too. The two major reasons are:
  1. It's an MSI standard bootstrapping solution (simplified bootstrapper is a Wix# lab research effort)
  2. It's just simpler:
var bootstrapper = new Bundle("My Product",
                       new MsiPackage(prerequisiteMsi),
                       new MsiPackage(productMsi) { DisplayInternalUI = true });

bootstrapper.Version = new Version("1.0.0.0");
bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889b");
bootstrapper.AboutUrl = "https://wixsharp.codeplex.com/";
...
bootstrapper.Build();
Jan 28, 2016 at 1:52 AM
Yes, I was trying the native bootstrapper, but the UI of the resulting setup did not seem neat to me because it's so different from the "standard" MSI UI.
Is that even possible to get the same outcome as with "simplified bootstrapper" meaning the main msi shows welcome dialog and checks whether the prerequisite product is installed and invokes its setup in the event of it's missing?
Coordinator
Jan 28, 2016 at 2:04 AM
> Is that even possible to get the same outcome as with "simplified bootstrapper" meaning the main msi shows welcome dialog and checks whether the prerequisite product is installed and invokes its setup in the event of it's missing?

No fortunately it's not. Though you can use a silent (no-UI) bootstrapper. This way your bootstrapper will take care about checking/installing your prerequisite and then displaying your usual main msi UI. It is almost what you want. There will be no bootstrapper UI that is true but the msi UI will only be displayed after the prerequisite step is complete. The following is a sample of bootstrapping .NET to your product setup:
var bootstrapper =
        new Bundle("My Product Suite",
            new PackageGroupRef("NetFx40Web"),
            new MsiPackage(productMsi) { Id = "MyProductPackageId", DisplayInternalUI = true });

bootstrapper.Version = new Version("1.0.0.0");
bootstrapper.UpgradeCode = new Guid("6f330b47-2577-43ad-9095-1861bb25889c");
bootstrapper.Application = new SilentBootstrapperApplication();

bootstrapper.Build();