使用 WiX 编写可升级的 msi 包
我正在为现有产品编写一个安装程序,该产品的早期安装程序是在 NSIS 中编写的( Nullsoft 脚本化安装系统)。我必须使用 WiX 为此产品编写一个基于 msi 的安装程序。我对此有一些疑问:-
- 如何检测我的应用程序是否安装在目标计算机上?该应用程序可能是使用 NSIS(旧版本)或 MSI(现在开始)安装的。
- 如何编写 WiX 安装程序,如果目标计算机上安装了较旧/相同版本的产品,则可以进行升级。我在几个网站上找到了这个主题,但所有这些都不起作用。具体来说,我想知道每个版本的软件的安装程序代码库中哪些信息(GUID、版本等)需要更改。
- 我们的产品每年发布三/四个版本。哪种安装程序最适合我?
请注意,如果我只是更改 Wix 代码中产品元素的版本,则新安装程序将无法替换旧安装程序。当我双击较新版本的安装程序时,它会显示一个错误对话框:
已安装此产品的另一个版本。无法继续安装此版本。要配置或删除此产品的现有版本,请使用控制面板上的“添加/删除程序”。
示例代码:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" >
<Product Name='Baton' Id='41B8F929-B6CF-41BE-9E40-C96D9BD6D672'
UpgradeCode='E1F03FA4-D470-4FA6-86BA-F5CDD3007C1D'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Company Name.'>
<Package Id='*' Keywords='Installer' Description="product Installer"
Comments='product comments'
InstallerVersion='100' Languages='1033' Compressed='yes'
SummaryCodepage='1252' />
<Upgrade Id='E1F03FA4-D470-4FA6-86BA-F5CDD3007C1D'>
<UpgradeVersion OnlyDetect='no' Property='PREVIOUSFOUND' Minimum='1.0.0'
IncludeMinimum='yes' Maximum='1.1.0' IncludeMaximum='yes' />
</Upgrade>
<!-- ***Install execution sequence*** -->
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize"/>
I am writing a installer for an existing product, for which an earlier installer was written in NSIS (Nullsoft Scriptable Install System). I have to write an msi based installer for this product using WiX. I have certain question regarding this :-
- How to detect whether my application is installed or not on a target machine? The application may have been installed using NSIS (older versions) or MSI (now onwards).
- How to write a WiX installer which can upgrade if there is older/same version of product installed on target machine. I found this topic on several sites but all those are not working. Specifically I want to know which information (GUID, version etc.) needs to be changed in the installer code base on each release of the software.
- Three/four versions of our product are released each year. What kind of installer will be best suitable for me?
Please note that if I just change version of the product element in Wix code, then the newer installer is not able to replace the older one. When I double click the newer version of the installer it shows an error dialog saying
Another version of this product is already installed. Installation of this version cannot continue.To configure or remove the existing version of this product, use Add/Remove Programs on the Control panel".
Sample code:
<?xml version='1.0' encoding='windows-1252'?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" >
<Product Name='Baton' Id='41B8F929-B6CF-41BE-9E40-C96D9BD6D672'
UpgradeCode='E1F03FA4-D470-4FA6-86BA-F5CDD3007C1D'
Language='1033' Codepage='1252' Version='1.0.0' Manufacturer='Company Name.'>
<Package Id='*' Keywords='Installer' Description="product Installer"
Comments='product comments'
InstallerVersion='100' Languages='1033' Compressed='yes'
SummaryCodepage='1252' />
<Upgrade Id='E1F03FA4-D470-4FA6-86BA-F5CDD3007C1D'>
<UpgradeVersion OnlyDetect='no' Property='PREVIOUSFOUND' Minimum='1.0.0'
IncludeMinimum='yes' Maximum='1.1.0' IncludeMaximum='yes' />
</Upgrade>
<!-- ***Install execution sequence*** -->
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize"/>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是当您使用完全相同的产品 ID 重建安装程序然后再次运行它时出现的错误。为了避免这种情况,请将产品元素 ID 设置为
Id="*"
。主要升级可以按照此答案中的方式实施。它的功能与示例代码大致相同,只是它使用预处理器变量来保持
Product
元素和UpgradeVersion
元素之间的版本一致。它还可以防止降级。This is the error you get when you rebuild your installer with the exact same product ID and then run it again. To avoid this, set the product element id to
Id="*"
.Major upgrades can be implemented as in this answer. It does about the same as your sample code, except that it makes use of preprocessor variables to keep the version consistent between the
Product
element and theUpgradeVersion
element. It also prevents downgrades.