首页 > 解决方案 > 有条件地安装基于安装目录的组件,WiX 安装程序

问题描述

我正在使用 WiX 工具集创建安装程序。

我正在使用 WixUI_InstallDir UI,因为我需要选择文件的安装位置。

我的要求是用户选择安装在 Program Files 中,一些文件(配置)应该放在 ProgramData 文件夹中,否则,它将位于安装目录本身中,

这就是我到目前为止所得到的。

    <!--Add Components in [ProgramData]/Configs-->
    <DirectoryRef Id="CommonConfigsFolder">
        <Component Id="ServiceConfigAppData" Guid="{1053F925-BEB3-4020-90C5-6EF163326B5E}">
          <Condition>
            <![CDATA[WIXUI_INSTALLDIR >< "Program Files"]]>
          </Condition>
          <CreateFolder>
            <Permission User="Everyone" FileAllRights="yes"/>
          </CreateFolder>
          <File Id="ServicesConfigFileAppData" KeyPath="yes" Source="$(var.ConfigPath)\Services.cfg"/>
        </Component>
    </DirectoryRef>

    <!--Add Components in [INSTALLFOLDER]/Configs-->
    <DirectoryRef Id="LocalConfigFolder">
      <Component Id="ServiceConfigLocal" Guid="{B4E52504-C4BF-4C99-88C4-5AF54D49E78A}">
        <Condition>
          <![CDATA[NOT (WIXUI_INSTALLDIR >< "Program Files")]]>
        </Condition>
        <CreateFolder>
          <Permission User="Everyone" FileAllRights="yes"/>
        </CreateFolder>
        <File Id="ServicesConfigFileLocal" KeyPath="yes" Source="$(var.ConfigPath)\Services.cfg"/>
      </Component>
    </DirectoryRef>

但它总是将文件写入安装目录,即使我安装在程序文件中

我必须定义 <Property Id="WIXUI_INSTALLDIR" Value="INSTALLFOLDER"/>才能使 WixUI_InstallDir 工作

标签: windows-installerwix3

解决方案


推荐阅读