本文介绍了WiX捆绑包bal:condition-util:RegistrySearch变量始终为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want my install to fail if a third-party software element is not installed. I added a Fragment with a util:RegistrySearch and a bal:Condition to the Bundle, but I can't get it to work. ThirdPartyCOMLibraryInstalled never evaluates to true. I've confirmed that the key exists, and the value I use for Key is correct - I copy/pasted the name from the selected key in regedit. There aren't any errors in the log.

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

I'm building the installer with WiXTools 3.7 in Visual Studio 2012 on Windows 7 64-bit and testing on both Windows XP SP3 and Windows 7 64-bit.

在线搜索util:RegistrySearch的其他示例,我遇到了以下用于条件测试表达式的替代形式.

Searching online for other examples for util:RegistrySearch I ran across the following alternative forms for the condition test expression.

  1. ThirdPartyCOMLibraryInstalled = 0-始终为错误
  2. ThirdPartyCOMLibraryInstalled <> 1-始终为真
  1. ThirdPartyCOMLibraryInstalled = 0 - always False
  2. ThirdPartyCOMLibraryInstalled <> 1 - always True

这是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中.

The root issue is that the RegistrySearch is in a separate Fragment that never gets referenced. Because nothing in the Fragment gets referenced the linker "optimizes away" the contents of the Fragment and the search is not included in your Bundle.

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

Fortunately, the solution is quite simple! You even have to choose from one of two:

  1. RegistrySearch元素移至Bundle元素.
  2. Bundle元素中添加RegistrySearchRef元素以引用Fragment中的RegistrySearch.您还需要提供RegistrySearchId属性.
  1. Move the RegistrySearch element to the Bundle element.
  2. Add a RegistrySearchRef element in the Bundle element to reference the RegistrySearch in the Fragment. You will also need to give the RegistrySearch and Id attribute.

就个人而言,我喜欢第二种方法,甚至可能将Condition移到Fragment中,并将所有内容组合在一起.类似于:

Personally, I like option two and I would probably even move the Condition into the Fragment as well to group all that stuff together. Something akin to:

<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捆绑包bal:condition-util:RegistrySearch变量始终为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 18:58