(I need to get this to work for the Product / .msi directly, not by using Bundle / Burn.)
(I am using WiX 3.6.)
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<?include $(sys.CURRENTDIR)Deployment\Data\Statics.wxi ?>
<Fragment>
<util:RegistrySearch Root="HKCU" Key="$(var.Line.Reg.Path)" Value="Version" Variable="AppAlreadyInstalled" />
</Fragment>
</Wix>
<Product Name="$(var.App.Title)" Manufacturer="!(loc.Company)" Language="!(loc.Lang)" Id="*" Version="$(var.VersionNumber)" UpgradeCode="$(var.App.UpgradeCode)">
<Package Id="*" InstallerVersion="300" Compressed="yes" InstallScope="$(var.App.Elevation)" InstallPrivileges="limited" />
<DirectoryRef Id="TARGETDIR" />
<MajorUpgrade Schedule="afterInstallValidate" DowngradeErrorMessage="!(loc.Msi.NewerVersionInstalled)" />
<Property Id='DiskPrompt' Value="$(var.App.Title) Installation Media" />
<Media Id="1" Cabinet="Media.cab" EmbedCab="yes" DiskPrompt="#1" />
<Icon Id="AppIcon" SourceFile="$(var.Icon.Path)" />
<Condition Message="Newer version already installed.">
<![CDATA[Installed OR AppAlreadyInstalled]]>
</Condition>
<Feature Id="ProductFeature" Level="1">
...
</Feature>
</Product>
WixUtilExtension:RegistrySearch
is only for bundles. You need a plain RegistrySearch
in the WiX namespace. You can use RegistrySearchRef to pull in a RegistrySearch from a separate fragment.
However, you're right that a version comparison is problematic: MSI does ordinal string comparisons so 1.2 > 1.10
. If the install directory is in the registry, you might be better off using a RegistrySearch combined with a DirectorySearch and a FileSearch. FileSearch
can search by version using the MinVersion
attribute so if there's a file with a version you can use to detect the product, it'll be more reliable than string comparisons.