【问题标题】:WiX Bundle bal:condition - util:RegistrySearch variable always falseWiX Bundle bal:condition - util:RegistrySearch 变量始终为假
【发布时间】:2013-04-13 01:41:13
【问题描述】:

如果未安装第三方软件元素,我希望我的安装失败。我在Bundle 中添加了Fragmentutil:RegistrySearchbal:Condition,但我无法让它工作。 ThirdPartyCOMLibraryInstalled 永远不会评估为真。我已经确认密钥存在,并且我用于 Key 的值是正确的 - 我从 regedit 中的选定密钥复制/粘贴了名称。日志中没有任何错误。

我正在 Windows 7 64 位的 Visual Studio 2012 中使用 WiXTools 3.7 构建安装程序,并在 Windows XP SP3 和 Windows 7 64 位上进行测试。

在网上搜索 util:RegistrySearch 的其他示例时,我遇到了条件测试表达式的以下替代形式。

  1. ThirdPartyCOMLibraryInstalled = 0 - 总是错误的
  2. 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>

【问题讨论】:

    标签: installation wix registry wix3.6


    【解决方案1】:

    根本问题是RegistrySearch 位于一个单独的Fragment 中,永远不会被引用。因为Fragment 中的任何内容都没有被引用,所以链接器“优化”了Fragment 的内容,并且搜索不包含在您的Bundle 中。

    除此之外:您可能会争辩说,在Condition 中的搜索中提到了对变量的引用,链接器应该能够确定搜索是必要的。但是,这并非在所有情况下都有效。

    幸运的是,解决方案非常简单!您甚至必须从以下两项中选择一项:

    1. RegistrySearch 元素移动到Bundle 元素。
    2. Bundle 元素中添加RegistrySearchRef 元素以引用Fragment 中的RegistrySearch。您还需要提供RegistrySearchId 属性。

    就个人而言,我喜欢选项二,我什至可能会将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>
    

    应该可以的。

    【讨论】:

    • 完全可以。谢谢你。我很乐意将此作为“操作指南”之一发布在 WiX 文档上,即“基于缺少的注册表项阻止引导程序安装”我能做些什么来实现这一点?
    • 听起来不错。要添加帮助,请针对 wix38 分支发送拉取请求,并更改以下文件:src\chm\html。代码在wix.codeplex.com
    猜你喜欢
    • 1970-01-01
    • 2017-03-25
    • 1970-01-01
    • 2012-08-20
    • 2016-04-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-03-05
    相关资源
    最近更新 更多