2
votes

I'm creating a custom wizard-style bootstrapper based on Wix/Burn (3.6 release version). I've based in on the Wix 3.6 bootstrapper code.

The problem is that I cannot get the bootstrapper to detect the install state of my setup.msi that is part of the bundle.

As I understand it, all that's required is to call Engine.Detect(), where Engine is an instance of the Wix Engine from the Bootstrapper Application. At that point I should be able to look in Bootstrapper.Command.Action to see what the required launch action is.

My bundle contains two items: .NET 4 (web install) and my setup.msi.

I suspect that I'm missing a step to determine whether I should put my wizard into maintenance mode vs. install mode.

2

2 Answers

4
votes

First, to determine if the package is being detected or not you can check the log files in the temp directory of the current user. It will tell you whether or not the package has been detected.

Now to determine whether or not to go into maintenance mode vs. install mode, you can check the package state by subscribing to the DetectPackageComplete event. In the example below, my UI uses two properties, InstallEnabled and UninstallEnabled to determine what "mode" to present to the user.

private void OnDetectPackageComplete(object sender, DetectPackageCompleteEventArgs e)
    {
        if (e.PackageId == "DummyInstallationPackageId")
        {
            if (e.State == PackageState.Absent)
                InstallEnabled = true;
            else if (e.State == PackageState.Present)
                UninstallEnabled = true;
        }
    }

The code sample above is from my blog post on the minimum pieces needed to create a Custom WiX Managed Bootstrapper Application.

3
votes

An easy way to determine if your Bundle is already installed is to use the WixBundleInstalled variable. That will be set to non-zero after your Bundle is successfully installed.

Additionally, in WiX v3.7+ the OnDetectBegin callback now tells you if the bundle is installed so you don't have to query the variable normally.

These changes were made to make it easier to detect maintenance mode to avoid the completely reasonable solution that @BryanJ suggested.