How to uninstall bundle when uninstalling msi in wix

25 Views Asked by At

We are using a Wix Bootstrapper to create an installation package and the CustomBA interface is implemented with WPF. App1 and App2 are mutually exclusive, and each time they are installed, there will be one app and one bundle in the application list. When upgrading, the lower version app is uninstalled but the bundle cannot be uninstalled. This results in two bundles and one app remaining in the list. Our requirement is that after each upgrade, there should only be one bundle or none, uninstalling the bundle. How should you modify this?

bundle.wxs is as follows

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <!--xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">-->
  <!--Project References and Variables-->
  <!--https://wixtoolset.org/documentation/manual/v3/votive/votive_project_references.html-->
  <Bundle Name="Bundle" Version="!(bind.packageVersion.Viewer)" Manufacturer=" Inc" UpgradeCode="03746b13-c047-4857-b74b-2c4a059a72f0" >
    <!--<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense">
            <bal:WixStandardBootstrapperApplication
             LicenseFile="..\..\License\license.rtf"
             ShowVersion="yes"/
        </BootstrapperApplicationRef>>-->
    <BootstrapperApplicationRef Id="ManagedBootstrapperApplicationHost" >
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)GalaSoft.MvvmLight.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)GalaSoft.MvvmLight.Extras.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)GalaSoft.MvvmLight.Platform.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)System.Windows.Interactivity.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)SharpCompress.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)Renci.SshNet.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)System.Memory.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)System.Runtime.CompilerServices.Unsafe.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)System.Buffers.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)System.Numerics.Vectors.dll" />
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)System.Text.Encoding.CodePages.dll" />
      <Payload Name="BootstrapperCore.config" SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetDir)\$(var.CustomBA _NewInstaller\CustomBA_.TargetFileName).config"/>
      <Payload SourceFile="$(var.CustomBA _NewInstaller\CustomBA_.TargetPath)" />
    </BootstrapperApplicationRef>
    <WixVariable Id="WixMbaPrereqLicenseUrl" Value=""/>
    <WixVariable Id="WixMbaPrereqPackageId" Value=""/>
    <Chain>
      <MsiPackage Compressed="yes" EnableFeatureSelection="yes" SourceFile="$(var.app1.TargetPath)" Visible="yes" Permanent="no"   Id="app1"/>
      <MsiPackage Compressed="yes" EnableFeatureSelection="yes" SourceFile="$(var.app2.TargetPath)" Visible="yes" Permanent="no" Id="app2"/>
    </Chain>
  </Bundle>  

The corresponding Bootstrapper event inside the viewmodel is as follows.

 private void BootstrapperApplication_DetectRelatedBundle(object sender, DetectRelatedBundleEventArgs e)
 {
     _isRelatedBundlePresent = true;
     var relatedVersion = e.Version;
     var process = Process.GetCurrentProcess();
     string fullPath = process.MainModule.FileName;
     var versionInfo = FileVersionInfo.GetVersionInfo(fullPath);
     var currentVersion = Version.Parse(versionInfo.FileVersion);
     if (relatedVersion >= currentVersion)
     {
         Uninstall();
        //Program.Dispatcher.InvokeShutdown();
     }
 }

Our requirement is that after each upgrade, there should only be one bundle or none, uninstalling the bundle. How should you modify this?

0

There are 0 best solutions below