wpfwixbootstrapperwix3.9

WIX Bootstrapper Upgrade - How to uninstall previous version silent


We have a wix setup (based on wix version 3.9) with a standard wix package together with a so called bundle that shows a wpf gui (with Bootstrapper etc), where we can install, update and uninstall the shabang. Everything should be "by the book" as far as I can see...

Now to the problem: We are able to upgrade by change the version numbers, but we can't seems to be able to disable the uninstallation GUI to popup during the process.

I'm running out of ideas and this is something others must have been solved but I don't find any real solution out there.

As it's managed in C# against the so called engine it's some kind of code there we need.

Currently the code is like this. In the Run method in my BA class:

    protected override void Run()
    {
        Dispatcher = Dispatcher.CurrentDispatcher;
        var model = new BootstrapperApplicationModel(this);
        Logging logging = new Logging(model);
        var view = new MainView(model, logging, this.RunMode);
        model.SetWindowHandle(view);
        this.Engine.Detect();
        view.Show();
        Dispatcher.Run();
        this.Engine.Quit(model.FinalResult);
    }

Then in the MainView class (or actually the viewmodel behind) acts on this:

    public void Activate(BootstrapperApplicationModel appModel, Logging modelLogging, LaunchAction runMode)
    {
        this.launchAction = runMode;
        this.model = appModel;
        this.logging = modelLogging;
        this.WireUpEventHandlers();
        this.OpenStartPageView();
    }

    private void WireUpEventHandlers()
    {
        this.model.BootstrapperApplication.PlanComplete += this.PlanComplete;
        this.model.BootstrapperApplication.ApplyComplete += this.ApplyComplete;
        this.model.BootstrapperApplication.ApplyBegin += this.ApplyBegin;
        this.model.BootstrapperApplication.ExecutePackageBegin += this.ExecutePackageBegin;
        this.model.BootstrapperApplication.ExecutePackageComplete += this.ExecutePackageComplete;
        this.model.BootstrapperApplication.PlanMsiFeature += this.SetPlannedFeature;
        this.model.BootstrapperApplication.DetectMsiFeature += SetFeatureDetectedState;
        this.model.BootstrapperApplication.DetectRelatedBundle += this.DetectRelatedBundle;
        this.model.BootstrapperApplication.DetectPackageComplete += this.DetectPackageComplete;
        this.model.BootstrapperApplication.Engine.Detect();
    }

Hopes that might gives some ideas how we have setup the gui.

It's feels that I need something like the below additional if case in the Activate function:

    public void Activate(BootstrapperApplicationModel appModel, Logging modelLogging, LaunchAction runMode)
    {
        this.launchAction = runMode;
        this.model = appModel;
        this.logging = modelLogging;
        if (this.launchAction == LaunchAction.Uninstall && /* something */)
        {
            this.model.PlanAction(this.launchAction); // Uninstall
            return;
        }

        this.WireUpEventHandlers();
        this.OpenStartPageView();
    }

But I have no idea how to pass information from the different versions...

Thanks in advance!


Solution

  • When doing an upgrade the newer version of the installation will call the previous version of the installation with the /q argument, which will give the installer BA the Command.Display = Display.None or Display.Embedded

    So in the above example with the if-case it will be like the following:

        public void Activate(BootstrapperApplicationModel appModel, Logging modelLogging, 
                             LaunchAction runMode, Display display)
        {
            this.launchAction = runMode;
            this.model = appModel;
            this.logging = modelLogging;
            this.displayMode = display;
            if (this.launchAction == LaunchAction.Uninstall && 
                (this.displayMode == Display.None || this.displayMode == Display.Embedded))
            {
                this.model.PlanAction(this.launchAction); // Uninstall
                return;
            }
    
            this.WireUpEventHandlers();
            this.OpenStartPageView();
        }
    

    Explaination what I did above: