Reputation: 1240
We are using WiX to create two packages for our product. Package A includes modules and other components that are prerequisites for Package B. I would like to prevent Package A from uninstalling when Package B is installed.
Can you recommend some techniques?
(I tried setting a property with UpgradeVersion/OnlyDetect along with a launch Condition, but discovered FindRelatedProducts is skipped during uninstall.)
@Cosmin has a good approach. What I've done is add a registry value to Package B containing Package A's UpgradeCode (thinking this will allow the dependency to be broken in the future should the need arise.)
<Component Id="RegistryInfo" Guid="*" Win64="$(var.Win64YesNo)">
<RegistryKey Id="CurrentVersion" Root="HKLM" Key="SOFTWARE\MYCO\PACKAGE_B\CurrentVersion" Action="create">
<RegistryValue Name="ProductVersion" Value="[ProductVersion]" Type="string" />
<RegistryValue Name="PackageAUpgradeCode" Value="$(var.PackageAUpgradeCode)" Type="string" />
</RegistryKey>
</Component>
Then Package A checks for the "dependency" during an uninstall.
<Property Id="PACKAGE_B_DEPENDS_ON">
<RegistrySearch Id="PackageAUpgradeCode" Root="HKLM" Key="SOFTWARE\MYCO\PACKAGE_B\CurrentVersion" Name="PackageAUpgradeCode" Type="raw" />
</Property>
<Condition Message='Package A is installed and requires this package.'>
not REMOVE = "ALL" or not PACKAGE_B_DEPENDS_ON = "$(var.PackageAUpgradeCode)"
</Condition>
Upvotes: 4
Views: 454
Reputation: 21436
A solution would be to use registry entries and searches:
If you don't like using the registry, you can also use file searches for installed files.
Please note that FindRelatedProducts detects older or newer versions of the same product. Windows Installer doesn't offer support for linking two packages.
Also, launch conditions are usually skipped during install. This is why an error custom action is a good approach.
Upvotes: 4