How do I make a WIX MSI always remove a previous version?

前端 未结 4 1121
栀梦
栀梦 2020-12-14 16:39

I have CI build system builds an MSI whenever a developer checks in a change. We run automated acceptance tests on the installed MSI.

Basically every MSI is a comple

相关标签:
4条回答
  • 2020-12-14 17:25

    You can use this code to remove the old version and install a newer one:

    <Product Id="*"
             UpgradeCode="87795f3dc95-81f5-473e-955e-2871a5bd66a5"
             Name="AppName"
             Language="1033"
             Version="1.0.6"
             Manufacturer="Manufacturer Name">
      <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
      <MajorUpgrade Schedule="afterInstallInitialize"
                    DowngradeErrorMessage="A later version of [ProductName] is already installed"
                    AllowSameVersionUpgrades="yes" />
    </Product>
    
    0 讨论(0)
  • 2020-12-14 17:29

    If the product code and version are the same yet the package code is different, you will always get that Windows Installer error message.

    I would strongly suggest including version information for your installers in your CI builds. If you are installing and subsequently upgrading each build, then versioning isn't a bad thing to have. It should be relatively easy to add this to a CI build.

    0 讨论(0)
  • 2020-12-14 17:36

    So I did find a way of doing it without changing the version number.

    I change the Product GUID with every build, but keep the Upgrade GUID the same.

    I also had to change the RemoveExistingProducts to Before='InstallInitialize'. Otherwise it left only the 'deltas' between builds in the install path.

    As noted by Wim below, I can replace the generated Product GUID with '*'.

    0 讨论(0)
  • 2020-12-14 17:46

    try

    <InstallExecuteSequence>
      <RemoveExistingProducts After='InstallFinalize' />
    </InstallExecuteSequence>
    

    This should remove any existing products after the install is finalised though you could customize the point at which you do it

    see http://mohundro.com/blog/2009/02/23/getting-started-with-wix-and-major-upgrades/

    also see the accepted answer for this question

    0 讨论(0)
提交回复
热议问题