WIX 安装程序 - 是否有任何管理产品 ID/代码的自动化方法? [英] WIX Installer - is there any automated way of managing Product ID / Code?

查看:25
本文介绍了WIX 安装程序 - 是否有任何管理产品 ID/代码的自动化方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Wix 开发 Windows 服务安装程序.据我了解,我应该为服务的每个版本生成一个唯一的产品 ID.这可以通过在 Product Id 属性中设置*"来轻松完成.但是,当我这样做并重建安装程序时,它为每个构建生成了不同的 guid.当我的机器上已经安装了任何版本的服务时,这会导致几个问题:即卸载过程完成后exe"文件仍然存在,控制面板中的程序中有多个完整的文件.

经过一番调查,我发现解决这个问题的方法是每次服务的版本号发生变化时手动更新产品 ID.还是我遗漏了什么?

无论如何,问题是:有没有办法使这个过程自动化,这样每次我构建相同版本的服务时 guid 都会相同,但仅在版本更新时更改?任何用于 Wix 的外部工具?

解决方案

构建自动化:您可以通过多种方式使用构建自动化来自动创建新的产品 GUID 等.您可以将值传递给 WiX 项目文件等,但这可能不是您想要维护的内容.让我在下面添加另一个选项.


主要升级元素:我假设您有一个主要升级元素?如果配置正确,它会负责卸载以前的版本.通常,当您重新构建同一版本并在上次安装的基础上进行安装时,您会在添加/删除程序"中看到多个版本.

建议:您可以手动配置升级表来卸载相同版本安装".你拿出自动魔法"MajorUpgrade"element 并使用 Upgrade elements(配置 Upgrade 表 产生更详细的控制):

删除此(或仅将其注释掉):

添加这个:

<!-- 新源代码的顶部 - 编译器变量,可以在编译时通过 candle.exe 和 light.exe 开关覆盖 --><?xml version="1.0";编码=UTF-8"?><?define MyProductVersion = "2.0.0.0";?><!-- 仅示例 GUID,请勿在您的包中使用 -><?define MyUpgradeCode = "88888888-7777-7777-7777-888888888888"?><.><Upgrade Id=$(var.MyUpgradeCode)"><UpgradeVersion 最小值=$(var.MyProductVersion)";OnlyDetect=是"IncludeMinimum=是"属性=DOWNGRADE_DETECTED"/><UpgradeVersion 属性 =PRODUCTLINE1"IncludeMinimum=是"IncludeMaximum=是"最大值=$(var.MyProductVersion)"最小值=0.0.0"/></升级><.><!-- 您必须将 RemoveExistingProducts 添加到 InstallExecuteSequence 表中 --><安装执行序列><!-- 潜在调度(之后):InstallValidate、InstallInitialize、InstallExecute、InstallExecuteAgain、InstallFinalize --><RemoveExistingProducts After="InstallInitialize";/></InstallExecuteSequence>

<块引用>

总结:以上应该可以让您重建设置并安装任意数量的次使用相同的版本号,安装过程将自动神奇地"删除先前的安装.请测试.没有保证.墨菲定律.等等... :-).


一些链接:

I'm developing a Windows Service installer using Wix. From what I understand, I should generate a unique Product ID for every Version of the service. This can be easily done by setting "*" in the Product Id attribute. However, when I do this and I rebuild the installer, it generated a different guid for every build. When I already have any version of service installed on my machine, this causes several problems: i.e. 'exe' file remaining after uninstall process being finished, multiple entires in Programs in Control Panel.

After some investigation, I found that the solution to this would be to update the Product Id manually every time when version number of the service would change. Or maybe I am missing something?

Anyway, the question is: is there any way to make this process automated, so that the guid would be same every time I build the same version of the service but change only when the version is updated? Any external tool for Wix?

解决方案

Build Automation: You can use build automation in a number of ways to automate the creation of new product GUIDs and similar. You would pass in values to the WiX project file and such things, but perhaps that is not what you want to maintain. Let me add another option below.


Major Upgrade Element: I assume you have a major upgrade element in there? It takes care of uninstalling the previous version if configured correctly. Typically you see multiple versions in Add / Remove Programs when you re-build the same version and install on top of the last installation.

Suggestion: You can manually configure the Upgrade table to uninstall "same version installations". You take out the "auto-magic" of the "MajorUpgrade" element and do things yourself with Upgrade elements (an older way to configure the Upgrade table that yields more detailed control):

Remove this (or just comment it out):

<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />

Add this:

<!-- The top of your new source - compiler variables, can be overridden at compile time via candle.exe and light.exe switches -->
<?xml version="1.0" encoding="UTF-8"?>
<?define MyProductVersion = "2.0.0.0" ?>

<!-- Sample GUID only, do not use in your package  ->
<?define MyUpgradeCode = "88888888-7777-7777-7777-888888888888" ?> 

<..>

<Upgrade Id="$(var.MyUpgradeCode)">
  <UpgradeVersion Minimum="$(var.MyProductVersion)" OnlyDetect="yes" IncludeMinimum="yes" Property="DOWNGRADE_DETECTED"  />
  <UpgradeVersion Property="PRODUCTLINE1" IncludeMinimum="yes" IncludeMaximum="yes" Maximum="$(var.MyProductVersion)" Minimum="0.0.0"  />
</Upgrade>

<..>

<!-- You have to add RemoveExistingProducts to the InstallExecuteSequence table -->
<InstallExecuteSequence>
  <!-- Potential scheduling (after): InstallValidate, InstallInitialize, InstallExecute, InstallExecuteAgain, InstallFinalize -->
  <RemoveExistingProducts After="InstallInitialize" />
</InstallExecuteSequence>

Summary: The above should let you rebuild your setup and install any number of times using the same version number and the installation process will remove prior installation "auto-magically". Please test. No guarantees. Murphy's law. Etc... :-).


Some Links:

这篇关于WIX 安装程序 - 是否有任何管理产品 ID/代码的自动化方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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