1

我需要让它直接为 Product / .msi 工作,而不是通过使用 Bundle / Burn。)

我使用的是 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>
  • 我相信AppAlreadyInstalled目前从未设置,因为它位于不同文件的片段中。
  • 然后,如果根本找不到注册表值/不存在,我实际上希望继续安装。
  • 但如果它确实存在,我希望仅在注册表值低于某个值时继续安装,例如,仅在AppAlreadyInstalled < 1.3.44时继续安装;这听起来很难实现,因为注册表值存储为带有两个句号/句点的字符串。
  • 注意注册表检查不是要安装的应用程序,它已经由 DowngradeErrorMessage 处理。
4

1 回答 1

2

WixUtilExtension:RegistrySearch仅适用于捆绑包。RegistrySearch您需要在 WiX 命名空间中使用纯文本。您可以使用RegistrySearchRef从单独的片段中提取RegistrySearch 。

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.

于 2012-07-23T05:00:17.640 回答