How to prevent WiX bundle with same UpgradeCode/Ve

2020-08-13 07:47发布

问题:

I have an application packaged with MSI that is made into a WiX bundle together with various required third-party tools. I have disabled modify and repair actions in the MSI du to how the application works, to require full uninstall before installing the same version again.

When I run the MSI separately, it works as expected: the installer cannot be run twice. The same applies when running the exact same Bundle again. But simply by rebuilding the bundle (using same UpgradeCodeand Version), the installation instead proceeds (much faster this time), and I end up with a duplicate entry among installed programs. I really would like to prevent that and make the bundle work as the MSI.

I have tried with various conditions set on the bundle; NOT WixBundleInstalled, WixBundleInstalled != 1, etc. But none of that seems to work.

For reference, here's the bundle statement:

<Bundle UpgradeCode="{FAF9CBDD-BE89-4B18-9921-FD5B426B5B0C}" IconSourceFile="$(var.SolutionDir)Resources\product.ico" 
          Name="Product 4.4" Version="4.4.0.0" Manufacturer="My Company" DisableModify="yes" Condition="NOT (WixBundleInstalled = 1)">

回答1:

If you add the OptionalUpdateRegistration tag, you will gain an entry in the registry you can use as an InstallCondition for your MSI package

<OptionalUpdateRegistration ProductFamily="MyProductFamily" Name="MyAppBundle"/>

<util:RegistrySearch Id="SearchForMyProduct" 
                     Root="HKLM" 
                     Key="SOFTWARE\WOW6432NODE\MyCompany\Updates\MyProductFamily\MyAppBundle" 
                     Value="PackageVersion" 
                     Result="exists" />

<MsiPackage Id="MyMsi"
            InstallCondition=SearchForMyProduct
            DisplayName="My Wonderful Product"
            SourceFile="MyProduct.msi"
            ForcePerMachine="yes"/>

This will prevent a new version of the bundle from installing "MyProduct" again. This will not prevent the bundle from installing it after you've already installed it from the MSI. To accomplish that, you can also have a RegistrySearch tag for a key created by your MSI.



回答2:

Add DisableRemove="yes" and DisableModify="yes" to Bundle and Visible="yes" for MSI. It couse show only MSI instance in Remove/Add programs.

<Bundle Name="InstallerBoot" Version="$(var.BuildVersion)" Manufacturer="Company" UpgradeCode="GUID" DisableRemove="yes" DisableModify="yes">
    ...
    <MsiPackage Id="MainPackage" SourceFile="..\Installer.msi" DisplayInternalUI="yes" Compressed="yes" Vital="no" Visible="yes">
</Bundle>

And change UpgradeCode in Bundle for each version.(In my program dont change upgradeCode was causing show additional bootstrapper windows after install msi)