Configure WiX project to install multiple versions, but remove same minor version

StackOverflow https://stackoverflow.com/questions/14709749

  •  06-03-2022
  •  | 
  •  

Question

I need to configure my WiX project to be able to install multiple minor versions of the product. IE: I can have 1.0, 1.1 and 1.3 installed. If I try to install 1.2, it will work, but if I try it with 1.1, it will uninstall the previous 1.1 installation before proceeding.

So far, this is what I have in my Upgrade tag:

<Upgrade Id="$(var.UpgradeCode)">
    <UpgradeVersion Minimum="$(var.MajorMinorVersion)" IncludeMinimum="yes" 
        Maximum="$(var.VersionNumber)" IncludeMaximum="no" Property="OLDERMINORFOUND"/>
</Upgrade>

UpgradeCode is a guid defined in my wxi file and MajorMinorVersion is the same as VersionNumber, but with the build at 0 (1.1.0 when the version is 1.1.12).

I'm guessing that I have two possibilities:

I make another UpgradeVersion tag or update the current one to have the maximum at the next minor version and exclude it from the search:

<UpgradeVersion Minimum="$(var.MajorMinorVersion)" IncludeMinimum="yes" 
        Maximum="$(var.NextMinorVersion)" IncludeMaximum="no"/>

Using a custom action to set NextMinorVersion somehow. Maybe using a property instead.

Or, change the UpgradeCode manually each time the minor version changes. Or have the first few characters of the guid represent the version and the rest be unique? I doubt that's a good idea though...

So basically, what would be the best way to accomplish this, in the hopes of having only one setup project for all versions?

EDIT

I've looked into the MajorUpgrade tag, but I don't think I can configure it to have many minor versions at the same time. Any light on this is appreciated.

I've also looked into making a preprocessor extension that would manipulate the version number using functions, so I could do this:

<Upgrade Id="$(var.UpgradeCode)">
    <UpgradeVersion Property="OLDERMINORFOUND"
        Minimum="$(var.MajorMinorVersion)" IncludeMinimum="yes" 
        Maximum="$(myprefix.NextMinor($(var.VersionNumber)))" IncludeMaximum="no"/>
</Upgrade>

See my answer for details.

Was it helpful?

Solution

So I wrote an extension as per the WiX manual (Part 1 and Part 2).

I made a preprocessor extension that takes a version number string (ex: 1.2.3.4) and manipulates the version by parsing and splitting the string.

So now I can write this in my .wxs file:

<Upgrade Id="$(var.UpgradeCode)">
    <UpgradeVersion Property="SAMEMINORFOUND" OnlyDetect="no"
        Minimum="$(var.MajorMinorVersion).0" IncludeMinimum="yes" 
        Maximum="$(version.NextMinor($(var.VersionNumber)))" IncludeMaximum="no" />
    <UpgradeVersion Property="OLDERVERSIONFOUND" OnlyDetect="yes"
        Maximum="$(var.MajorMinorVersion).0" IncludeMaximum="no"/>
    <UpgradeVersion Property="NEWERVERSIONFOUND" OnlyDetect="yes"
        Minimum="$(version.NextMinor($(var.VersionNumber)))" IncludeMinimum="yes"/>
</Upgrade>

<InstallExecuteSequence>
    <RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>

Where version.NextMinor is a call to my preprocessor extension.

So my installer will only detect installations of the product unless the minor versions match, where it will be uninstalled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top