我正在开发一套相关的应用程序,它们都有自己的 WiX 安装程序。您可以想象,这些安装程序之间有很多重复,我正在尝试对此做些什么。为此,我创建了一个包含一些.wxs文件的 WiX 库项目,并且我一直在尝试将尽可能多的代码放入这些.wxs文件中。到目前为止,大部分工作都很好。但是,有一件事我似乎无法移至 a .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,我使用与 for 相同的值Product/@UpgradeCode。(我不确定这是否有必要,甚至是好的做法。)我想WixVariable在某个时候把它放在 a 中,但现在我正试图让它与文字 GUID 一起工作。
我已经将CustomActions 和 theInstallExecuteSequence移到了Fragment我的.wxs文件中。我已经定义了 aWixVariable来包含 ProductName,所以我可以让每个应用程序的安装程序显示自己的名称。这正是我想要和期望的方式。
但是,当我将Upgrade元素移动到 a中时Fragment(无论它是在应用程序的Product.wxs文件中还是在库文件之一中,并且它是否与包含 的同一个.wxs也无关紧要),以下问题发生:FragmentInstallExecuteSequence
- 如果我首先运行旧版本的安装程序,然后将新版本的安装程序
Upgrade移到单独的Fragment, 但具有相同Product/@Version的Product@/UpgradeCode, 和Upgrade/@Id, 我最终会安装 2 次相同的产品,这显然不是我想要的。 - 如果我安装新的安装程序两次,它不会安装第二次(这是我想要的),但它也不会显示我的错误消息。
我会用 a 替换整个东西MajorUpgrade,如果不是因为 1)它似乎不想在再次安装相同版本时给出错误消息,更重要的是,2)它不允许在 aFragment出于某种原因,所以我仍然坚持重复(尽管比以前少了很多)。
那么......我怎样才能在不丢失当前功能的情况下将我的Upgrade元素移动到库中?.wxs我究竟做错了什么?