Can't understand that the program is uninstalling

Aug 29, 2016 at 10:09 AM
My installer has ManagedUI.
I click Remove button in MaintenanceTypeDialog. In BeforeInstall event handler e.IsUninstalling is false.
Why is it false?

Remove button click event handler:
void remove_Click(object sender, System.EventArgs e)
MsiRuntime.Session["REMOVE"] = "All";

int index = Shell.Dialogs.IndexOf(ProgressDialog);
if (index != -1)
Aug 30, 2016 at 8:57 AM
Thank you for reporting this. I have created an issue report on your behalf:
It is solved in codebase right now and the fix will be available in the next release. But the binaries can be already downloaded from Git.
As a work around you can change your code as this:
MsiRuntime.Session["REMOVE"] = "ALL";
Sep 22, 2016 at 9:25 AM
Hi, Oleg!
There is the same problem in managed project with standart UI.
I click Remove button in MaintenanceTypeDialog. In BeforeInstall and AfterInstall event handlers e.IsUninstalling is false.
Sep 22, 2016 at 2:15 PM
Edited Sep 22, 2016 at 5:00 PM
I need to clarify. When you execute your msi and facing MaintenanceTypeDialog (managed or standard) you are always is in maintenance mode. That is it. As far as MSI runtime concerned you are modifying but not uninstalling the product. The fact that you clicked 'Remove' button doesn't change anything. You didn't start your msi with '/uninstall' switch then you are not uninstalling but modifying.

In ManagedUI I have an opportunity to intercept remove button click and set MsiRuntime.Session["REMOVE"] = "ALL"; so effectively I start uninstalling and e.IsUninstalling returns true. But native UI doesn't set REMOVE property so it is not installing but modifying (by removing all components).

Effectively it means that the properties of SetupEventArgs for native UI can only reliably report you how your setup was started but not to trace your input in the native setup UI.

Where does it leave you? You can dig WiX/MSI documentation find out what combination of properties signifies pressing Remove button during Modifying. If you find one please share it with me and I will update the IsUninstalling implementation.

You can try to find this combination by yourself. I couldn't but I captured the screenshots of SetupEvents sample so it can be a good start point for you:

But arguably the most practical solution is something like this:
if (e.IsUninstalling)
    //do your uninstalling stuff
else if (e.IsModifying)
    if (<your product files are present>)
        //do your uninstalling stuff
Sep 22, 2016 at 2:25 PM
Edited Sep 22, 2016 at 4:59 PM
And of course you can also avoid all these troubles if you stop allowing user to modify (only repair and uninstall) your setup. This way unninstalling can be determined reliably