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>
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) 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) 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>
So in the InstallCondition, chkProductA evaluates to true when the UI is used and the respective checkbox is checked, and ProductAInstalled 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...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With