installation - WiX bundle :condition - util:RegistrySearch variable always false

标签 installation wix registry wix3.6

如果未安装第三方软件元素,我希望我的安装失败。我加了一个 Fragmentutil:RegistrySearch和一个 bal:ConditionBundle ,但我无法让它工作。 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 中的元素元素引用 RegistrySearchFragment .您还需要提供 RegistrySearchId属性。

  • 就我个人而言,我喜欢选项二,我什至可能会移动 ConditionFragment以及将所有这些东西组合在一起。类似于:
    <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/

    相关文章:

    wpf - WIX Bootstrapper 升级 - 如何静默卸载以前的版本

    registry - HKEY_LOCAL_MACHINE\SOFTWARE\Classes 与 HKEY_CLASSES_ROOT

    c++ - 连续调用 RegGetValue 会为同一字符串返回两种不同的大小

    android - Wear 上不允许安装/卸载操作

    sql-server - WiX:DB Restore 不恢复表和记录

    node.js - Git 中的 NodeJs 安装问题

    properties - 在卸载日志中找不到 WiX 属性

    registry - REG 文件中的注释

    linux - 无法在cpanel上运行Elasticsearch(Linux)

    c++ - flens lapack : GNU GCC Version 4. 7 或更高要求!我的 mac 有