Wix/MSI - 如何避免安装相同的 MSI 两次
我的安装程序是用 WiX 语言编码的。支持重大升级机制。一个特殊的要求是相同的 MSI 文件无法安装两次。
现在出现了棘手的部分:如果用户安装然后尝试再次安装(UI 模式),安装程序将进入维护模式一切正常(更改/修复将显示为禁用。)
但是,当按照我们的用例状态在静默模式下安装时
msiexec.exe /i installer.msi /qn
第二个安装将继续正常安装(我们不想要这个!)
需要注意的一些事情是:
在第二次安装的日志文件中,将跳过序列“FindRelatedProducts”(如 Microsoft 文档 http://msdn.microsoft.com/en-us/library/windows/desktop/aa368600(v=vs.85).aspx)
但是,我被困在这里:因为我必须避免安装比当前版本更早或相同的版本并允许更大的升级,我如何在 WiX 中实现这一目标?
感谢您的帮助!
I have my installer coded in WiX language. It supports major upgrade mechanism. A particular requirement is that the same MSI file will not be possible to install twice.
Now comes the tricky part: if user install and then try to install it again (UI mode) the installer enters in maintenance mode and everything works OK (Change/Repair will appear disabled.)
However when installing as our use case states in silent mode
msiexec.exe /i installer.msi /qn
The second install will proceed to install as normal (we don't want this!)
Some things to noticed about are:
In the log file of the second installation the sequence "FindRelatedProducts" will be skipped (as state in microsoft documentation http://msdn.microsoft.com/en-us/library/windows/desktop/aa368600(v=vs.85).aspx)
Also I research a bit an here http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/UpgradeVersion-is-not-detecting-the-same-version-preventing-downgrades-td5875840.html there is good information, claiming that for this scenarios we can used Installed property to detect if Product is already installed...
However, I get stuck here: because I have to avoid installing previous or same versions than current one and allowing upgrades greater, How could I achieve this in WiX?
Thanks for your help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
首先,您应该修复升级代码:
请注意,每次构建安装时都会重新创建产品代码(不使用 GUID,而是使用星号)。
基本信息是产品版本和升级代码。产品代码标识特定的部署版本,而升级代码标识产品版本“系列”。具有相同升级代码的软件可以相互切换。具有相同产品代码的软件不能一起安装。
以下是升级软件的技巧:
通过使用上面的标记,当 Wix 发现具有相同 UpgradeCode 的产品但已安装的产品具有 版本 时,您可以告诉 Wix 中止安装em> 大于当前版本,但如果他发现具有相同 UpgradeCode 的产品且已安装产品的 版本 小于当前版本,则开始安装(升级当前版本)当前的一个。
IncludeMinimum 和 IncludeMaximum 应该可以解决问题,允许升级跳过当前版本。
Wix 不安装相同的产品:您应确保已安装的软件和 MSI 打包的软件的产品代码相同:如果不同,则它们是不同的部署软件。除此之外,如果产品具有与 MSI 相同的产品代码,则安装会提供修复/更改选项:要禁用它们,您必须使用 Wix 软件包的“属性”表,通过引入ARP_ 变量(您可以禁用修复、更改和卸载,还可以设置制造商联系人和其他属性)。
这是 ARP变量列表。我不知道在静默模式下安装时它们的行为是什么,但是如果您从命令行调用 msiexec,则有一个特定的修复选项可以发出修复(/f),那么如果您是,它如何自动修复您的产品不要求?
First all, you shall fix your upgrade code:
Note that the product code is recreated each time you build the installation (by not using the GUID but the asterisk).
The fundamental information is the product version and the upgrade code. The product code identify the specific deployed release, while the upgrade code identity the product releases "family". Softwares having the same upgrade code can be switched with each other. Softwares having the same product codes cannot be installed toghether.
Here is the trick to make upgrade you software:
By using the above markup, you say to Wix abort installation when he find a product having the same UpgradeCode but the installed one has a Version greater than the current one, but begin the installation (upgrading the current one) if he find a product having the same UpgradeCode and the installed one has a Version less than the current one.
The IncludeMinimum and IncludeMaximum shall do the trick, allowing the upgrade to skip the current version.
Wix doesn't install the same product: you shall be sure that the product code is the same for installed software and MSI-packaged software: if they are different, they are different deployed softwares. Beyond this, if the product has the same product code of the MSI, the installation offers the repair/change options: to disable them you have to play with the Property table of the Wix package, by introducing the ARP_ variables (you can disable repair, change and uninstall, but also setup manufacturer contacts and other properties).
Here is the ARP variable list. I don't know what is their behavior when installing in silent mode, but if you are invoking msiexec from command line, there is a specific repair option to issue repair (/f), so how can it automatically repair your product if you are not requesting?
这是不可能的。
当尝试安装已安装的软件包时,Windows Installer 会自动执行修复。没有升级过程。
另外,维护过程是根据ProductCode触发的。第二次启动程序包时,Windows Installer 发现其 ProductCode 已安装并进入维护模式。它与升级没有任何关系。
仅当更改 ProductVersion 和 ProductCode 时才使用升级。
编辑:
要防止在维护模式下自动修复,您可以尝试以下操作:
This cannot be done.
When trying to install an already installed package, Windows Installer automatically performs a repair. There is no upgrade process.
Also, the maintenance process is triggered based on ProductCode. When launching your package the second time Windows Installer sees that its ProductCode is already installed and enters maintenance mode. It's not related in any way to upgrades.
Upgrades are used only when changing the ProductVersion and ProductCode.
Edit:
To prevent an automated repair in maintenance mode you can try this: