我正在开发一套相关的应用程序,它们都有自己的WiX安装程序。正如你可以想象的那样,这些安装程序之间有很多重复,我正试图对此做些什么。为此,我使用一些WiX文件创建了一个.wxs库项目,并一直试图将尽可能多的代码插入到这些.wxs文件中。到目前为止,它的效果还算不错。但是,有一件事我似乎无法移动到.wxs:Upgrade元素。
这是我的升级代码:
<Upgrade Id="MY-UPGRADE-CODE-GUID">
<!-- If an older version is found replace it -->
<UpgradeVersion OnlyDetect="no" Property="OLDERFOUND"
Maximum="$(var.ProductVersion)" IncludeMaximum="no"/>
<!-- If the same version is found do nothing (OnlyDetect) -->
<UpgradeVersion OnlyDetect="yes" Property="SELFFOUND"
Minimum="$(var.ProductVersion)" IncludeMinimum="yes"
Maximum="$(var.ProductVersion)" IncludeMaximum="yes"/>
<!-- If a newer version is found do nothing (OnlyDetect) -->
<UpgradeVersion OnlyDetect="yes" Property="NEWERFOUND"
Minimum="$(var.ProductVersion)" IncludeMinimum="no"/>
</Upgrade>
<CustomAction Id="AlreadyUpdated" Error="This version of !(wix.Param.Upgrade.ProductName) is already installed. You will have to uninstall it manually before this installer can continue."/>
<CustomAction Id="NoDowngrade" Error="A newer version of !(wix.Param.Upgrade.ProductName) is already installed. You will have to uninstall that version manually before this installer can continue."/>
<InstallExecuteSequence>
<RemoveExistingProducts After="InstallInitialize"/>
<!-- If the same version is found execute AlreadyUpdated -->
<Custom Action="AlreadyUpdated" After="FindRelatedProducts">SELFFOUND</Custom>
<!-- If a newer version is found execute NoDowngrade -->
<Custom Action="NoDowngrade" After="FindRelatedProducts">NEWERFOUND</Custom>
</InstallExecuteSequence>对于Upgrade/@Id,我使用与Product/@UpgradeCode相同的值。(我不确定这是必要的,甚至是良好的做法。)我想在某个时候将其放在WixVariable中,但目前我正试图使它与文字GUID一起工作。
我已经将CustomAction和InstallExecuteSequence移到了.wxs文件中的Fragment中。我已经定义了一个WixVariable来包含ProductName,所以我可以让每个应用程序的安装程序显示自己的名字。这正是我想要和期待的方式。
但是,当我将Upgrade元素移动到Fragment中(无论它是在应用程序的Product.wxs文件中还是在库.wxs文件中,以及Fragment是否与包含InstallExecuteSequence的Fragment相同的情况下),都会出现以下问题:
Upgrade的新版本移到单独的Fragment中,但是使用相同的Product/@Version、Product@/UpgradeCode和Upgrade/@Id,我最终会安装两个相同的产品,这显然不是我想要的。如果没有这样的事实,我会用MajorUpgrade来代替整个程序: 1)当再次安装相同的版本时,它似乎不想给出错误消息;更重要的是,由于某些原因,它不允许在Fragment中运行,所以我仍然被复制所困扰(尽管比以前少了很多)。
所以..。如何在不丢失当前功能的情况下将Upgrade元素移动到.wxs库中?我做错了什么?
发布于 2012-07-03 12:32:07
正如在wix链接器文档中所描述的,链接器在构建windows数据库时将遵循片段之间的引用。但这意味着它将忽略产品wxs未引用的任何片段(直接或间接地通过其他片段)。
这种行为在您的场景中可能非常有用,因为它允许您对所有可重用组件之间的依赖关系进行建模,链接器将确保只包含特定产品所需的依赖项。
为了确保包含升级逻辑,您有两个选择:
https://stackoverflow.com/questions/11308396
复制相似问题