问题描述
我有一个刻录安装,用户可以从中选择三个选项中的哪一个进行安装-每个选项都与链中三个MsiPackages中的一个直接相关,例如:
I've a burn installation whereby the user can select which of three options to install - each one directly relates to one of three MsiPackages in a chain, such as :
<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.
All fine. However, when I run the msi next time, I only want to re-install/update the items that were selected originally - ie if only productA was selected, I don't want to install products B & C.
如何确定最初选择的内容?
How do I determine what was originally selected?
推荐答案
好的,对它进行排序,所以我最好发布解决方案.
OK,Sorted it, so I'd best post my solution.
最终它可以归结为两个部分...
Ultimately it boils down to two parts...
a)在安装时设置的每个产品MSI中设置一个注册表项.显然,如果最初未安装该MSI,则注册表项将不存在.即
a) setting a registry key in each of the Product MSI's which are set on installation. Obviously if that MSI was not installed originally, then the registry entry will not exist. i.e.
<!-- 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)进行升级时检查刻录中是否存在该注册表项...
b) Checking for the existence of that registry key in burn when doing the upgrade...
<!-- 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的评估结果为true-请注意在没有任何用户交互的情况下进行的更新(对于我而言).
So in the InstallCondition,chkProductA evaluates to true when the UI is used and the respective checkbox is checked, andProductAInstalled evaluates to true when the respective product has already been installed - taking care of the update which in my case happens without any user interaction.
当您知道如何时就很容易.我当然不是从...开始的.
Easy when you know how. I certainly didn't to start with...
这篇关于WiX Burn-确定已经安装了哪些项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!