Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

ProductVersion Comparison Logic


5 replies to this topic

andyguest13

andyguest13
  • Full Members
  • 21 posts

Posted 27 November 2013 - 10:58

Hi.

Can anyone detail the algorithm Windows Installer employs for its comparison of two ProductVersion strings?

 

I saw a post where Stefan said that it does an alphabetic compare of the 1st three fields...but what exactly does that mean?

 

I have an existing product 2.01.01 and a new one 2.1.4.0 and I am currently thinking that Windows Installer thinks the former is newer than the latter

 

thanks

andy

 



Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 27 November 2013 - 14:36

There's no special function for number comparison.

Numerical comparison is only used in the Upgrade table where you can enter product version specific conditions (where only the first 3 fields are compared), and when overwriting files (where all four file version fields are used).

But comparing property values using operators like <, > etc. will permorm a string comparison.

 

So the question is: which functionality are you using to do the comparison?



VBScab

VBScab
  • Full Members
  • 436 posts

Posted 28 November 2013 - 09:16

an existing product 2.01.01 and a new one 2.1.4.0

Awesome consistency on display here.

 

If this is your product, decide which version numbering you're going to use and stick with it. If it's an external vendor...how are they still in business if they're dishing out junk like this?!?!?


- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

andyguest13

andyguest13
  • Full Members
  • 21 posts

Posted 28 November 2013 - 11:09

?? The two version strings I quoted are perfectly valid and the 2nd is a consistent jump up in build sequence: in both cases major version is 2, minor is 1; we're on the fourth build. In the real world you have to sometimes inherit software anyway.

 

I am not doing any version string comparisons myself, I was wondering how Windows Installer did it under the hood itself. I presume, the algorithm is like so but I wanted confirmation, especially regarding those leading zeros:

 

tokenMajor = extractTokenToPeriod(&szProductVersion1[0]);

int iMajor1 = atoi(tokenMajor);

 

tokenMinor = extractTokenToPeriod(tokenMajor);

int iMinor1 = atoi(tokenMinor);

 

tokenBuild = extractTokenToPeriod(tokenMinor);

int iBuild1 = atoi(tokenBuild);

 

// same for the other string2....

 

bool isNewer = (iMajor2>iMajor1) || (iMinor2>iMinor1) || (iBuild2>iBuild1);

 

 

you get the drift of the logic


VBScab

VBScab
  • Full Members
  • 436 posts

Posted 29 November 2013 - 10:43

Hmmm...I'd like to knpow what numnbering system has the number '1' following in sequence to the "number" '01', as in:

 

2.01.01

2.1.4.0

 

For consistency, shouldn't the second string be '2.01.04.0'? Then your comparison logic can be made to simply test (and optionally discard) leading zeroes.


- Don't know why 'x' happened? Want to know why 'y' happened? ProcMon will tell you.
- Try using http://www.google.com before posting.
- I answer questions only via forums. Please appreciate the time I give here and don't send me personal emails.

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 29 November 2013 - 16:25

Hmm, not sure if the version numbers are really the issue here. What are the symptoms you are seeing? Major Upgrade not removing previous version so you end up with two Add/Remove programs entries? Files not being updated? How does your Major Upgrade entry look like in the Upgrade table? What does the log say about FindRelatedProducts?

 

And for a sanity check: please open the built msi file in InstEd, Orca or a similar editor and look at the ProductVersion.

 

The leading zeros look unusual but shouldn't hurt. Since ProductVersion is actually compared using integers, 2.01.01 = 2.1.1. But even in an alphabetical comparison "2.01.01" < "2.4.1". This would only be a problem if you used 2.1.1. and 2.04.01.