简体   繁体   中英

How to prevent WiX bundle with same UpgradeCode/Version to be installed twice

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 UpgradeCode and 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)">

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM