1

I decided to ask my question here because I can't find answer in any other place. My task is to prepare upgrade process with managed bootstrapper UI, but it doesn't want to work properly. I prepared all of needed MSI packages. I mean I added Product Id="*", I added MajorUpgrade tag and configured it and I change versions between bundle(for test purposes), I also added a few properties which should helps me with distinguish is it an Install, Uninstall or Upgrade process.

And my problem starts here, because when I was using default burn UI it worked properly I mean during installation property _INSTALL was set to 1, during upgrade (installing version 2 of bundle) property _UPGRADE was set to 2 and the same with uninstallation, but now when I added Custom UI to that, UPGRADE property isn't set at all. Instead of that during trial of UPGRADE first starts Installation process and it goes to some point and then new window with Uninstallation appears.

My question is can I somehow make my Custom UI to behave like a Default UI for burn?

  • Can you post your code, Michal? – Eric Sep 26 '18 at 20:03
  • [There are a couple of links to Managed Bootstrapper Application samples in this answer](https://stackoverflow.com/a/52349744/129130) (towards bottom). I suppose you could also look at [**WiX's own installer source code for its Managed Bootstrapper Application**](https://github.com/wixtoolset/wix3/tree/develop/src/Setup/WixBA) - for the actual WiX 3 installer itself - in other words. Maybe you are looking at this already? At least I think the latter is the right location for the WiX source code. – Stein Åsmul Sep 27 '18 at 03:26

1 Answers1

0

Thank you everyone for comments. Inspired by How to perform Wix Upgrade with custom bootstrapper I understood I didn't handle situation when installer is run quietly.

So I prepared another class for SilentUninstall and did it in my Bootstrapper class:

public class BootstrapperApp : BootstrapperApplication
{
    public static Dispatcher Dispatcher { get; set; }

    protected override void Run()
    {
        Dispatcher = Dispatcher.CurrentDispatcher;

        var model = new BootstrapperApplicationModel(this);
        var command = model.BootstrapperApplication.Command;
        if (command.Action == LaunchAction.Uninstall && (command.Display == Display.None || command.Display == Display.Embedded))
        {
            model.LogMessage("Starting silent uninstaller.");
            var viewModel = new SilentUninstallViewModel(model, Engine);
            Engine.Detect();
        }
        else
        {
            model.LogMessage("Starting installer.");
            var viewModel = new InstallViewModel(model);
            var view = new InstallView(viewModel);

            view.Closed += (sender, e) => Dispatcher.InvokeShutdown();

            model.SetWindowHandle(view);

            Engine.Detect();
            view.Show();
        }
        Dispatcher.Run();
        Engine.Quit(model.FinalResult);
    }}

and my SilentUninstaller class:

public class SilentUninstallViewModel
{
    private BootstrapperApplicationModel model;
    private Engine engine;

    public SilentUninstallViewModel(BootstrapperApplicationModel model, Engine engine)
    {
        this.model = model;
        this.engine = engine;
        WireUpEventHandlers();
    }

    private void WireUpEventHandlers()
    {
        this.model.BootstrapperApplication.PlanComplete += PlanCompleted;
        this.model.BootstrapperApplication.DetectComplete += DetectCompleted;
        this.model.BootstrapperApplication.ApplyComplete += ApplyCompleted;
    }

    private void DetectCompleted(object sender, DetectCompleteEventArgs e)
    {
        this.model.LogMessage("Detecting has been completed for silent uninstallation.");
        this.model.PlanAction(LaunchAction.Uninstall);
    }

    private void ApplyCompleted(object sender, ApplyCompleteEventArgs e)
    {
        this.model.LogMessage("Applying has been completed for silent uninstallation.");
        this.model.FinalResult = e.Status;
        this.engine.Quit(this.model.FinalResult);
    }

    private void PlanCompleted(object sender, PlanCompleteEventArgs e)
    {
        this.model.LogMessage("Planning has been started for silent uninstallation.");
        model.ApplyAction();
    }
}

and it seems to works properly. Even property _UPGRADE is raised in particular MSIs ;)