Set up your WiX project to install multiple versions, but remove the same minor version

I need to set up my WiX project to install multiple minor product versions. IE: I can install 1.0, 1.1 and 1.3. If I try to install 1.2 it works, but if I try it from 1.1 it uninstalls the previous 1.1 installation before proceeding.

So far, this is what I have in the tag Upgrade

:

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

      

UpgradeCode

is the manual defined in my wxi file and is the MajorMinorVersion

same as VersionNumber

but line at 0 (1.1.0 if version is 1.1.12).

I assume I have two possibilities:

I make another tag UpgradeVersion

or update the current one to have the maximum size in 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 install in NextMinorVersion

some way. Perhaps use a property instead.

Or change the UpgradeCode manually each time the minor version changes. Or does the first few characters of the guide represent the version and the rest are unique? I doubt it's a good idea though ...

Basically, what would be the best way to achieve this, in the hope that there will be only one project for all versions?

EDIT

I looked at the tag MajorUpgrade

, but I don't think I can tweak it to have multiple minor versions at the same time. Any light on this is appreciated.

I also looked into creating a preprocessor extension that will manipulate the version number with 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.

+3


source to share


1 answer


So, I wrote an extension according to the WiX tutorial ( Part 1 and Part 2 ).

I made a preprocessor extension that takes a version number string (ex: 1.2.3.4) and processes 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 the call to my preprocessor extension.

This way, my installer will only detect product installations if the minor versions are the same, where it will be uninstalled.

+2


source







All Articles