gvasko
Posts: 33
Joined: Mon Jun 07, 2010 7:11 pm

Comparing version numbers

Hi,

I tried to set up a launch condition that would compare two version numbers.
I suppose only string comparison is available.
So my question is: how to compare version numbers.

For example:

VersionA=1.2.38
VersionB=1.2.88
VersionA < VersionB is true

but,
VersionB=1.2.110
VersionA < VersionB gives false in a condition.

Thank you,
Gabor Vasko
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Comparing version numbers

Hello Gabor,

Could you explain why you need this behavior?

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
gvasko
Posts: 33
Joined: Mon Jun 07, 2010 7:11 pm

Re: Comparing version numbers

I still don't have enough experience in the field of deployment, so perhaps I use some concepts wrong.

We have two merge modules, a .NET module and a module with shared native dlls and COM components (shared module). The msi installer contains both of them.
The versions of the .NET module is installed side-by-side, however, we would like always the latest version of the shared modules to be installed.

That's why I tried to use version comparison as I found in this forum topic: http://www.advancedinstaller.com/forums ... f=1&t=6912.
I attached each modules to separated features in order to disable the shared module if it's not necessary to be installed based on conditional install level. The shared module puts its version number into the registry, and the msi compares that version number with the current one.

Now I suppose I should put each component of the version number separately into the registry for correct comparison.
Or should I create a separated msi installer for the shared module with auto upgrade?

Thanks,
Gabor Vasko
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: Comparing version numbers

Hello again,

You can try using an Extended Search. Set the criteria to "Registry value containing a version". You can then fill in the Minimum and/or the Maximum fields to restrict the search. This search should search for the registry value containing the current version of your shared component. If this value is not at least the version specified in the Minimum field, the search would fail and you would install your version of the shared module.

Let me know if this helps.

Best regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
gvasko
Posts: 33
Joined: Mon Jun 07, 2010 7:11 pm

Re: Comparing version numbers

Hi Gabriel,

Yes, this works well.
Thank you.

Gabor Vasko
tdo
Posts: 5
Joined: Wed Apr 26, 2017 7:47 pm

Re: Comparing version numbers

Sorry for digging up this old thread but I'm having a similar problem although a bit different. I want to have a property to be set to either true or false based on whether a version in the registry is at least a minimum version, so that I can use that property in different part of the installer, not just when installing prerequisite. Is it possible to do this?

Also, can Advanced Installer compare versions of the form X.Y.Z.W, instead of just X.Y?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Comparing version numbers

Hi,

In order to achieve this you can create a registry search to get the version from the registry, then add a "Set installer property" that set another property based on the value of that search. A property is true when it is set to any value and false when it is empty.

Yes, Advanced Installer can compare versions of the "X.Y.Z.W" form.

Let me know if you need more details.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
tdo
Posts: 5
Joined: Wed Apr 26, 2017 7:47 pm

Re: Comparing version numbers

When I compare the version number, do I use the >, <, >= and <= operators? Do those operators correctly compare version number (for example 1.10 is bigger than 1.9), or do they just do normal string comparison (which will make 1.10 less than 1.9)?
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Comparing version numbers

Hi,

Yes, those operators can be used to compare the versions. Unfortunately, they are compared as strings, not versions (1.10 is less than 1.9).

To compare them as versions, you can create your own custom action with this functionality.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
tdo
Posts: 5
Joined: Wed Apr 26, 2017 7:47 pm

Re: Comparing version numbers

I was hoping I could make use of the existing version comparison when checking for prerequisite, without having to write a custom action myself. Thank you for your aid.
Eusebiu
Posts: 4971
Joined: Wed Nov 14, 2012 2:04 pm

Re: Comparing version numbers

The version comparison is available for a prerequisite in the "Install Conditions" tab of that prerequisite. Unfortunately it is not available for custom properties, too.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”