WiX Installer:获取要升级产品的版本 [英] WiX Installer: getting version of the product being upgraded

查看:98
本文介绍了WiX Installer:获取要升级产品的版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在从X版本到Y版本的重大升级期间,我需要有一个属性/变量,说明X版本正在升级.

During a major upgrade from version X to version Y, I need to have a property/variable stating that version X is being upgraded.

使用WiX Installer构建的安装程序对产品进行重大升级时,是否可以获取正在升级的版本号?

When performing a Major Upgrade of a product with a setup built by WiX Installer, is there a way to get the version number being upgraded?

推荐答案

假设您使用的是WiX majorupgrade元素,则在检测到升级时,WIX_UPGRADE_DETECTED属性的值将设置为要升级产品的产品代码.您可以将其传递给C ++ Win32 API MsiGetProductInfo(.... INSTALLPROPERTY_VERSIONSTRING ...)以获取版本字符串.我认为您可以使用该产品代码构造一个DTF等效产品ProductInstallation类,然后获取版本.如果您不使用majorupgrade元素,那么仍然会存在诸如PREVIOUSVERSIONSINSTALLED之类的属性,该属性将被设置为产品代码,因此它完全取决于您如何设置它.请注意,严格来说,您可能要升级多个产品.这将在FindRelatedProducts之后完成.无论如何,这就是我要看的.

Assuming you're using a WiX majorupgrade element, when an upgrade is detected the value of the WIX_UPGRADE_DETECTED property is set to the productcode of the product being upgraded. You could pass that into the C++ Win32 API MsiGetProductInfo (.... INSTALLPROPERTY_VERSIONSTRING...) to get the version string. I think there's a DTF equivalent, ProductInstallation class that you construct with that productcode and then get the version. If you didn't use the majorupgrade element there is still a property like PREVIOUSVERSIONSINSTALLED that will get set to the productcode, so it depends on exactly how you've set it up. Note that strictly speaking you could be upgrading more than one product. This would be done after FindRelatedProducts. Anyway, that's what I'd look at.

我认为没有内置的方式来获取版本.您需要知道升级实际上将首先进行,因此您需要使用FindRelatedProducts升级搜索设置的属性.您还可以做其他事情,但是我不知道它们是否可以在您遇到的情况下起作用.例如,如果您要从外部程序启动MSI,则它可以将相关产品枚举到MSI的产品代码,获取版本并将其作为属性传递给命令行,以减少MSI需要做的事情(假设升级正在进行中)工作,但在您的情况下可能没有用.

I don't think there's a built-in way to get the version. You'd need to know that the upgrade is actually going to work first, so you'd need the property that is set by the FindRelatedProducts upgrade search. There are other things you could do, but I don't know if they would work in your situation. For example if you were launching the MSI from an external program it could enumerate related products to the MSI's productcode, get the version and pass it as a property on the command line to reduce what the MSI would need to do, assuming the upgrade is going to work, but that may be useless in your situation.

这篇关于WiX Installer:获取要升级产品的版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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