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

冷暖自知 提交于 2020-06-11 17:07:13

问题


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:


I am dont know it is good solution. But I managed to do it this way:

Add DisableRemove="yes" and DisableModify="yes" to Bundle and Visible="yes" for MSI.

<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>

This causes that in 'Add Remove Programs' it does not add the boostrapper, but the msi, which can be updated without problems with the new version.



来源:https://stackoverflow.com/questions/23783045/how-to-prevent-wix-bundle-with-same-upgradecode-version-to-be-installed-twice

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!