WiX:比较版本“7.x.x.x"和“10.x.x.x" [英] WiX: Compare version "7.x.x.x" and "10.x.x.x"

查看:22
本文介绍了WiX:比较版本“7.x.x.x"和“10.x.x.x"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 WiX 文件,我必须在其中进行版本比较以检查先决条件.表达式看起来像这样:

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>

这一直工作正常,因为主要版本号从 7 到 8 到 9.我们现在转向版本 10,字符串比较失败,因为1"小于7".我希望 "10.0"<"7.0" 评估为 false 因为我打算比较版本,但表达式评估为 true 因为正在发生的字符串比较.

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.

我已经检查了几个 StackOverflow 的答案以及 WiX 文档,但似乎缺少版本比较操作.

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.

我可以为 WiX 使用什么方法?

What approach can I use for WiX?

推荐答案

MSI SDK:是的,正如 MSI SDK 所述:"注意,安装程序不会直接比较条件语句中的Version数据类型.例如,您不能使用比较运算符来比较诸如01.10"和1.010"之类的版本条件语句.而是使用有效方法来搜索版本,例如 搜索现有应用程序、文件、注册表项或 .ini 文件项,然后设置属性."

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.

您在 Publish 元素中到底在做什么?

What exactly are you doing in that Publish element?

这篇关于WiX:比较版本“7.x.x.x"和“10.x.x.x"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆