WIX 目录搜索总是失败

标签 wix conditional-statements

似乎无论我做什么,我在 WIX 中放入我的产品的任何条件都会阻止我的安装运行。下面我放了一些简单的代码,用于检查程序文件目录是否存在,如果存在,则运行安装程序。我收到一条消息,提示“未找到程序文件文件夹”。指示条件返回false。我在这里缺少什么?

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="SetupProject1" Language="1033" Version="1.0.0.0" Manufacturer="Toshiba" UpgradeCode="bb557911-769b-4a30-8461-3ad860ddc10e">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
    <MediaTemplate />

<Property Id="PFFOLDER" >
  <DirectorySearch Id="SystemFolderDriverVersion" Path="[ProgramFilesFolder]">
  </DirectorySearch>
</Property>

<Condition Message="Program files folder not found.">
  <![CDATA[PFFOLDER]]>
</Condition>


    <Feature Id="ProductFeature" Title="SetupProject1" Level="1">
        <ComponentGroupRef Id="ProductComponents" />
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="INSTALLFOLDER" Name="SetupProject1" />
        </Directory>
    </Directory>
</Fragment>

<Fragment>
    <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
        <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
        <!-- <Component Id="ProductComponent"> -->
            <!-- TODO: Insert files, registry keys, and other resources here. -->
        <!-- </Component> -->
    </ComponentGroup>
</Fragment>

最佳答案

将 AssignToProperty="yes"添加到 DirectorySearch 元素。此外,我认为您不需要将属性名称包装在 CDATA 块中。

关于WIX 目录搜索总是失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29547348/

相关文章:

licensing - WIX:如何在安装过程中更改许可协议(protocol)

gradle - WiX/SetupBuilder在vbscript中获取INSTALLDIR的值

c++ - SSE 的条件语句

algorithm - 如何采用此条件语句并在没有 if-then 语句的情况下重写它

python - 如何检查没有参数发送到 Python 中的函数

从R中的数据框中删除重复的行,保留具有较小/较大值的行

c# - 包含许多子文件夹和文件的 WiX 安装程序

com - 为什么 Regasm 将 ProgId 放入 HKEY_CURRENT_USER 中?

wpf - 除非以管理员身份运行,否则使用 WiX 安装的应用程序将无法正常工作

string - Bash 脚本 - 检查文件是否包含特定行