我正在构建一个WiX 捆绑包。我需要链接一个可执行包(实际上是ASCOM Platform 6 SP1)。检测条件是存在某个注册表项,并且包含大于某个最低要求版本的版本号。如果不满足这些条件,则不满足先决条件,需要下载并安装 EXE 文件包。
我编写的片段如下所示:
<?xml version="1.0" encoding="UTF-8"?>
<?include $(sys.CURRENTDIR)\Config.wxi?>
<!-- Define a prerequisite for ASCOM Platform 6 SP1 -->
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
<Fragment>
<util:RegistrySearch Id="FindAscom6Installed"
Variable="AscomPlatform6Installed"
Root="HKLM"
Key="SOFTWARE\ASCOM\Platform"
Value="Platform Build"
Result="exists"
Win64="$(var.Win64)"
/>
<util:RegistrySearch Id="FindAscom6Build"
Variable="AscomPlatformBuild"
Root="HKLM"
Key="SOFTWARE\ASCOM\Platform"
Value="Platform Build"
Result="value"
Win64="$(var.Win64)"
/>
<PackageGroup Id="AscomPlatform6Sp1">
<!-- If necessary, install ASCOM Platform version 6, do not uninstall
it during driver uninstall. -->
<!-- DetectCondition="AscomPlatformInstalled AND AscomPlatformBuild >= 6.0.10028.2207" -->
<ExePackage
SourceFile="ASCOMPlatform6SP1.exe"
DetectCondition="AscomPlatform6Installed AND AscomPlatformBuild >= 6.0.10028.2207"
DownloadUrl="http://download.ascom-standards.org/ASCOMPlatform6SP1.exe"
PerMachine="yes"
Permanent="yes"
Vital="yes" />
</PackageGroup>
</Fragment>
</Wix>
这可以编译,但是当安装程序运行时,它会失败。这是日志输出:
[0E54:141C][2012-12-12T06:37:38]i001: Burn v3.7.1204.0, Windows v6.2 (Build 9200: Service Pack 0), path: C:\Users\Tim\Documents\visual studio 2012\Projects\Wix.BurnTutorial\Wix.BurnTutorial\bin\Debug\Wix.BurnTutorial.exe, cmdline: ''
[0E54:141C][2012-12-12T06:37:38]i000: Setting string variable 'WixBundleLog' to value 'C:\Users\Tim\AppData\Local\Temp\Wix.BurnTutorial_20121212063738.log'
[0E54:141C][2012-12-12T06:37:38]i000: Setting string variable 'WixBundleOriginalSource' to value 'C:\Users\Tim\Documents\visual studio 2012\Projects\Wix.BurnTutorial\Wix.BurnTutorial\bin\Debug\Wix.BurnTutorial.exe'
[0E54:141C][2012-12-12T06:37:38]i000: Setting string variable 'WixBundleName' to value 'Wix.BurnTutorial'
[0E54:141C][2012-12-12T06:37:39]i100: Detect begin, 2 packages
[0E54:141C][2012-12-12T06:37:39]i000: Registry key not found. Key = 'SOFTWARE\ASCOM\Platform'
[0E54:141C][2012-12-12T06:37:39]i000: Registry key not found. Key = 'SOFTWARE\ASCOM\Platform'
[0E54:141C][2012-12-12T06:37:39]i000: Setting numeric variable 'AscomPlatform6Installed' to value 0
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to parse condition "AscomPlatform6Installed AND AscomPlatformBuild >= 6.0.10028.2207". Unexpected character at position 51.
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to read next symbol.
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to parse value.
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to parse term.
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to parse boolean-factor.
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to parse boolean-term.
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to parse boolean-term.
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to parse expression.
[0E54:141C][2012-12-12T06:37:39]e051: Error 0. Failed to parse condition AscomPlatform6Installed AND AscomPlatformBuild >= 6.0.10028.2207. Unexpected symbol at position (null)
[0E54:141C][2012-12-12T06:37:39]e000: Error 0x8007000d: Failed to evaluate executable package detect condition.
[0E54:141C][2012-12-12T06:37:39]e151: Detect failed for package: ASCOMPlatform6SP1.exe, error: 0x8007000d
[0E54:141C][2012-12-12T06:37:39]i101: Detected package: ASCOMPlatform6SP1.exe, state: Unknown, cached: None
[0E54:141C][2012-12-12T06:37:39]i101: Detected package: TargetPackage, state: Absent, cached: None
[0E54:141C][2012-12-12T06:37:39]i199: Detect complete, result: 0x8007000d
我怀疑问题可能是,因为密钥不存在,所以AscomPlatform6Build为空,WiX 不喜欢。
如何正确构建此检测条件?