WiX - How to uninstall the bundle when uninstall t

2019-02-24 10:20发布

问题:

Im using WiX to install my .msi, I´m generating a WiX Bundle using the Bundle Element. I try to not show the Bundle on "Add/Remove programs" so i set the properties of the Bundle element like this:

<Bundle Name="$(var.ProductName)" Version="!(bind.packageVersion.MSIPackage)" 
      Manufacturer="$(var.ProductManufacturer)" UpgradeCode="$(var.UpgradeCode)" 
      DisableRemove="yes" DisableModify="yes" DisableRepair="yes">

DisableRemove, DisableModify and DisableRepair to "yes" made the Bundle be hidden under "Add/Remove programs".

My problem is that when i Uninstall my application, the application is uninstalled correctly but the Bundle remains Hidden, so it cause some problems when i try to install other version of the App, for example the new Bundle detects that there are other Bundle installed and performs some versioning check and so on.

So my question is: is possible to when the application in uninstalled from the "Add/Remove programs" uninstall the Hidden Bundle as well?

回答1:

To expand on Tom's answer, if you remove the Disables from your Bundle tag

<Bundle Name="$(var.ProductName)" Version="!(bind.packageVersion.MSIPackage)"
        Manufacturer="$(var.ProductManufacturer)" UpgradeCode="$(var.UpgradeCode)">

You can modify your MsiPackage tag to hide the MSI from Add/Remove Programs

  <MsiPackage
      Id="YOUR-ID"
      Vital="yes"
      DisplayName="$(var.ProductName)"
      SourceFile="$(var.Source.TargetPath)">

    <MsiProperty Name="ARPSYSTEMCOMPONENT" Value="1"/>

  </MsiPackage>

This will leave just one entry in Add/Remove Programs. Your Bundle will now handle the UI of the install and uninstall, and will correctly allow other versions of the bundle to be installed.



回答2:

Well, you could use a custom action in the msi but don't.

You have inverted the designed relationship between bundles and packages. I suggest that you hide the package and show the bootstrapper in ARP.

The bootstrapper engine ("burn") is a package manager that collaborates with Windows Installer. Together they handle upgrades and uninstallation of packages. If, after understanding how it works, you don't want what it does then you may want a self-extractor instead of burn. (Some projects that do use burn are Visual Studio and WiX itself.)



回答3:

Use -repair option when running the installer every time. It's a hack but it works. The problem is that the bundle uninstall is hidden, and when running uninstall you are only removing the package inside, not the bundle.

This causes the issue when you want to run the installation again after uninstalling the package inside. The installer thinks that the bundle is still installed. By using the -repair option (every time you install the bundle), you are telling it to either install the bundle if no bundle is present. or repair it if the package was removed.

-repair = repair (or install if not installed)