Search code examples
wixlimitupgrade

Wix: How to limit major upgrades to major version numbers?


I need the following behaviour from my wix-based installers:

  • Every setup in the major version 1.x.x line should majorupdate any previous version of the 1.x.x line.
  • Every setup in the major version 2.x.x line should majorupdate any previous version of the 2.x.x line but leave the 1.x.x line alone.

I though I could get this to work with the following code, but the setup removed the previous 1.x.x version. Am I mssing something? Is this even possible?

    <Upgrade Id="myguid">
        <UpgradeVersion OnlyDetect="yes" Minimum="2.0.0.1" Property="NEWERVERSIONDETECTED" IncludeMinimum="no" />
        <UpgradeVersion OnlyDetect="no" Maximum="2.0.0.1" Property="OLDERVERSIONBEINGUPGRADED" IncludeMaximum="no" />
    </Upgrade>
    <InstallExecuteSequence>
        <RemoveExistingProducts After="InstallInitialize" />
    </InstallExecuteSequence>

Solution

  • You need to use a NEW GUID for 2.x if you don't want it to be "aware" of 1.x (i.e. ignore it, don't care, etc)

    I use the following code, only changing var.Property_UpgradeCode when I want a new version to ignore previously installed versions (e.g. exist side-by-side in different folders)

    <Product Id="*"
             UpgradeCode="$(var.Property_UpgradeCode)"
             Name="!(loc.ApplicationName)"
             Language="!(loc.Property_ProductLanguage)"
             Version="$(var.version)"
             Manufacturer="!(loc.ManufacturerName)" >
    
    <MajorUpgrade AllowSameVersionUpgrades="yes"
              DowngradeErrorMessage="!(loc.LaunchCondition_LaterVersion)"
              MigrateFeatures="no"
              Schedule="afterInstallInitialize" />