WiX: Compare version “7.x.x.x” and “10.x.x.x”

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-24 12:19:13

问题


I have a WiX file where I have to do a version comparison to check prerequisites. The expression looks something like this:

<Publish (attributes...)>
    <![CDATA[(VERSION<"7.0") OR (other expressions)]]>
</Publish>

This was working fine until now as the major version numbers went 7 to 8 to 9. We are now moving to version 10 and the string comparison is failing as "1" is less than "7". I would like "10.0"<"7.0" to evaluate to false as I intend to compare versions, but the expression evaluates to true because of the string comparison that is happening.

I have checked several StackOverflow answers as well as WiX documentation, but it seems like a version comparison operation is missing.

Ideally, in a programming language, if there was no version parsing mechanism, I would split the string by the . and converted the string to integer and compared the corresponding entries.

What approach can I use for WiX?


回答1:


MSI SDK: Yes, as the MSI SDK states: "Note that the installer will not do direct comparisons of the Version data type in conditional statements. For example, you cannot use comparative operators to compare versions such as "01.10" and "1.010" in a conditional statement. Instead use a valid method to search for a version, such as described in Searching for Existing Applications, Files, Registry Entries or .ini File Entries, and then set a property."

The question remains if searching and setting properties is a viable approach for you. You can also use a custom action and inspect the system in more flexible ways - if you really need to.

What exactly are you doing in that Publish element?



来源:https://stackoverflow.com/questions/55351177/wix-compare-version-7-x-x-x-and-10-x-x-x

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!