gpt4 book ai didi

WiX Burn - 确定已经安装了哪些项目

转载 作者:行者123 更新时间:2023-12-04 06:06:10 25 4
gpt4 key购买 nike

我有一个刻录安装,用户可以选择安装三个选项中的哪一个 - 每个选项都直接与链中的三个 MsiPackages 之一相关,例如:

<Chain>
<MsiPackage SourceFile="..\ProductA\bin\Release\ProductA.msi" InstallCondition="chkProductA" />
<MsiPackage SourceFile="..\ProductB\bin\Release\ProductB.msi" InstallCondition="chkProductA" />
<MsiPackage SourceFile="..\ProductC\bin\Release\ProductC.msi" InstallCondition="chkProductC" />
</Chain>

一切都很好。但是,当我下次运行 msi 时,我只想重新安装/更新最初选择的项目 - 即如果只选择了 productA,我不想安装产品 B 和 C。

我如何确定最初选择的是什么?

最佳答案

好的,
排序它,所以我最好发布我的解决方案。

最终它归结为两个部分......

a) 在安装时设置的每个产品 MSI 中设置一个注册表项。显然,如果最初未安装该 MSI,则该注册表项将不存在。 IE。

  <!-- registry entry to state that the item has been installed-->
<Component Id="cmp_WriteToRegistry" Guid="[yourguid]">
<RegistryKey Root="HKLM"
Key="Software\MyCompany]"
Action="createAndRemoveOnUninstall">
<RegistryValue Type="integer" Name="ProductA" Value="1" KeyPath="yes"/>
</RegistryKey>
</Component>

b) 在升级时检查该注册表项是否存在刻录...
<!-- Determine what items are to be installed in the event of an install using the BA-->
<WixVariable Id="chkProductA" Value="![CDATA[chkProductA]]" />
<WixVariable Id="chkProductB" Value="![CDATA[chkProductB]]" />
<WixVariable Id="chkProductC" Value="![CDATA[chkProductC]]" />

<!-- Determine what items are installed in the event of an upgrade-->
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\MyCompany" Value="ProductAInstalled" Variable="ProductAInstalled" Result="exists" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\MyCompany" Value="ProductBInstalled" Variable="ProductBInstalled" Result="exists" />
<util:RegistrySearch Root="HKLM" Key="SOFTWARE\MyCompany" Value="ProductCInstalled" Variable="ProductCInstalled" Result="exists" />

<Chain>
<MsiPackage SourceFile="..\SetupProductA\bin\Release\SetupProductA.msi"
InstallCondition="chkProductA OR ProductAInstalled" />
<MsiPackage SourceFile="..\SetupProductB\bin\Release\SetupProductB.msi"
InstallCondition="(chkProductB) OR (ProductBInstalled)" />
<MsiPackage SourceFile="..\SetupProductC\bin\Release\SetupProductC.msi"
InstallCondition="(chkProductC) OR (ProductCInstalled)" />
</Chain>

</Bundle>

所以在 InstallCondition 中,
当使用 UI 并选中相应的复选框时,chkProductA 评估为 true,并且
当相应的产品已经安装时,ProductAInstalled 评估为真 - 处理更新,在我的情况下发生没有任何用户交互。

当你知道怎么做的时候很容易。我当然不是一开始...

关于WiX Burn - 确定已经安装了哪些项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12917287/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com