Wix bundles have two points where you can configure whether they should execute or not.
The first which you'll find is the bundle/@Condition attribute:
<Bundle Name="TestBundle" Version="1.0.0.0" Manufacturer="TestDeploy Inc." UpgradeCode="Here the condition checks that at least NT in version 6.0 (Windows Server 2008) is installed with at least ServicePack 2, or that the windows versions bigger than 6.1 (Windows 7). Microsoft provides a list of the windows versions." Condition="((VersionNT = v6.0) AND (ServicePackLevel >= 2)) OR (VersionNT >= v6.1)" > <!-- bundle stuff --> </Bundle>
This can only be used with prebuilt wix burn variables. A list of those can be found here: http://wix.sourceforge.net/manual-wix3/bundle_built_in_variables.htm.
The second method requires the WixBalExtension's Condition element:
<bal:Condition Message="The Bootstrapper has to be installed in version $(var.BaselineVersion)"> WixBundleInstalled OR ((SampleMsiInstalledState = 5) AND (SampleMsiInstalledVersion >= v$(var.BaselineVersion))) </bal:Condition> <util:ProductSearch Guid="[msi_prerequisite_package_product_code]" Result="version" Variable="SampleMsiInstalledVersion" /> <util:ProductSearch Guid="[msi_prerequisite_package_product_code]" Result="state" Variable="SampleMsiInstalledState" />Here we use a ProductSearch from the WixUtilExtension to find the state and versions of related msi packages. The version is then compared to the minimum version of a bundle that's required for the bundle (BasellineVersion).
I haven't found a way to search for installed bundles, but it is apparently possible to do a registry search for the bundle UpgradeCode. However, that's wix implementation details and should be used with care.
What i found important is: Use some kind of fallback condition, like the WixBundleInstalled (this variable is 1 if installed, 0 else). Without that, the SampleMsiInstalledState could be false because someone forced the bundle to uninstall, then the conditions would evaluate to false and the bundle won't run anymore. No user likes bundle corpses on the system.
Keine Kommentare:
Kommentar veröffentlichen