我有一个刻录安装,用户可以选择安装三个选项中的哪一个 - 每个选项直接与链中三个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&amp;下进行。
如何确定最初选择的内容?
答案 0 :(得分:10)
行, 对它进行排序,所以我最好发布我的解决方案。
最终归结为两部分......
a)在安装时设置的每个产品MSI中设置注册表项。显然,如果最初没有安装MSI,那么注册表项将不存在。即。
<!-- 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在已安装相应产品时评估为true - 在我的情况下进行更新,而无需任何用户交互。
当你知道怎么做时很容易。我当然不会开始......
答案 1 :(得分:3)
如果您正在使用自己的托管引导程序,则可以在DetectPackageComplete事件处理程序中执行此操作:
CustomBA_DetectPackageComplete(object sender, DetectPackageCompleteEventArgs e)
{
if (e.PackageId == "SetupProductA" && e.State == PackageState.Present)
{
CustomBA.Engine.NumericVariables["chkProductA"] = 1;
}
etc...
}
可以使用DetectMsiFeature
来检测已安装的功能。
话虽如此,如果您已经拥有自定义BA,我只会使用此方法。构建自定义BA是很多的工作。