Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 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)">
like image 642
Torbjörn Bergstedt Avatar asked May 21 '14 12:05

Torbjörn Bergstedt


1 Answers

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.

like image 171
philselmer Avatar answered Nov 02 '22 16:11

philselmer