如果未安装第三方软件元素,我希望我的安装失败。我加了一个 Fragment
与 util:RegistrySearch
和一个 bal:Condition
到 Bundle
,但我无法让它工作。 ThirdPartyCOMLibraryInstalled
从不评估为真。我已经确认 key 存在,以及我用于 Key
的值是正确的 - 我从 regedit 中选择的键中复制/粘贴了名称。日志中没有任何错误。
我正在 Windows 7 64 位上的 Visual Studio 2012 中使用 WiXTools 3.7 构建安装程序,并在 Windows XP SP3 和 Windows 7 64 位上进行测试。
在线搜索 util:RegistrySearch
的其他示例我遇到了以下条件测试表达式的替代形式。
ThirdPartyCOMLibraryInstalled = 0
- 总是错误 ThirdPartyCOMLibraryInstalled <> 1
- 永远正确 这是
Bundle
代码:<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
xmlns:netfx="http://schemas.microsoft.com/wix/NetFxExtension"
xmlns:bal="http://schemas.microsoft.com/wix/BalExtension">
<Bundle Name="!(bind.packageName.MyApp)"
Version="!(bind.packageVersion.MyApp)"
Manufacturer="!(bind.packageManufacturer.MyApp)"
UpgradeCode="a07ce1d5-a7ed-4d89-a7ee-fb13a5dd69ba"
Copyright="Copyright (c) 2013 [Bundle/@Manufacturer]. All rights reserved."
IconSourceFile="$(var.My_Application1.ProjectDir)MyCo.ico">
<bal:Condition Message="ThirdParty Application COM Library Required. Please (re)install ThirdParty Application and ensure 'Windows API' and '.NET Components' are installed."
>ThirdPartyCOMLibraryInstalled</bal:Condition>
<Variable Name="InstallFolder"
Type="string"
Value="[ProgramFilesFolder]MyCo Systems\My_Application\"/>
<BootstrapperApplicationRef
Id="WixStandardBootstrapperApplication.HyperlinkLicense" >
<bal:WixStandardBootstrapperApplication
ThemeFile="Resources\HyperlinkTheme.xml"
LaunchTarget="[InstallFolder]My_Application.exe"
LocalizationFile="Resources\HyperlinkTheme.wxl"
SuppressRepair="yes"
SuppressOptionsUI="yes"
LicenseUrl=""
LogoFile="Resources/MyCoLogoWt64.png"
/>
</BootstrapperApplicationRef>
<Chain>
<PackageGroupRef Id="NetFx40Redist"/>
<MsiPackage Id ="MyApp"
Vital="yes"
Name="My Application"
SourceFile="$(var.MyApp_Install.TargetDir)MyApp_Install.msi">
<MsiProperty Name="INSTALLLOCATION"
Value="[InstallFolder]" />
</MsiPackage>
</Chain>
</Bundle>
<Fragment>
<util:RegistrySearch
Variable="ThirdPartyCOMLibraryInstalled"
Result="exists"
Root="HKLM"
Key="SOFTWARE\Classes\ThirdPartyId.Server\CLSID"/>
</Fragment>
</Wix>
最佳答案
根本问题是 RegistrySearch
在单独的 Fragment
中永远不会被引用。因为在Fragment
中什么都没有被链接器“优化掉”了 Fragment
的内容并且搜索不包含在您的 Bundle
中.
Aside: you could argue that the fact that there is a reference to the variable mentioned in the search in the
Condition
that the linker should be able to figure out that the search is necessary. However, that doesn't work out in all cases.
幸运的是,解决方案非常简单!您甚至必须从以下两项中进行选择:
RegistrySearch
元素到 Bundle
元素。 RegistrySearchRef
Bundle
中的元素元素引用 RegistrySearch
在 Fragment
.您还需要提供 RegistrySearch
和 Id
属性。 就我个人而言,我喜欢选项二,我什至可能会移动
Condition
进Fragment
以及将所有这些东西组合在一起。类似于:<Bundle ...>
<util:RegistrySearchRef Id='SearchForThirdParty' />
...
</Bundle>
<Fragment>
<util:RegistrySearch
Id='SearchForThirdParty'
Variable="ThirdPartyCOMLibraryInstalled"
Result="exists"
Root="HKLM"
Key="SOFTWARE\Classes\ThirdPartyId.Server\CLSID"/>
<bal:Condition Message="ThirdParty Application COM Library Required. Please (re)install ThirdParty Application and ensure 'Windows API' and '.Net Components' are installed.">ThirdPartyCOMLibraryInstalled</bal:Condition>
</Fragment>
</Wix>
那应该这样做。
关于installation - WiX bundle :condition - util:RegistrySearch variable always false,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16108405/