【问题标题】:In Wix, how can I avoid hardcoding a file source for a file that already exists in the installation directory?在 Wix 中,如何避免硬编码安装目录中已存在的文件的文件源?
【发布时间】:2013-07-09 20:39:12
【问题描述】:

在我的 .wxs 文件中,我有以下文件声明。此文件已存在于安装目录中。它不是从源目录复制的。我需要在安装过程中使用 util:XmlConfig 对其进行更新。 XmlConfig 部分正在工作。

<File Id="AppConfig" Name="Dynamics.exe.config" Source="C:\Program Files (x86)\Microsoft Dynamics\GP2010\Dynamics.exe.config" />

问题是我不能假设文件总是存在于同一个位置。我真的很想像这样简单地引用它:

<File Id="AppConfig" Name="[#INSTALLDIR]\Dynamics.exe.config" />

但是,失败并显示以下消息:

> light.exe ....
The system cannot find the file 'SourceDir\....\[#INSTALLDIR]\Dynamics.exe.config'

如何说“安装目录中已经存在该文件,安装过程中使用该文件,现在不验证”?

【问题讨论】:

    标签: wix wix3 dynamics-gp


    【解决方案1】:

    目录可以使用括号表示法,就好像它们是常规属性一样。如果您不需要安装 Dynamics.exe.config 只需使用 XmlConfig 元素访问它,您可以简单地引用该目录,而无需打扰 File 元素:

    <Component Id="Dynamics.exe.config" KeyPath="yes" Guid="*">
      <util:XmlConfig Id="Dynamics.exe.config.XmlConfig1"
                      On="install"
                      Action="..."
                      File="[INSTALLDIR]\Dynamics.exe.config"
                      ...
                      />
      <util:XmlConfig Id="Dynamics.exe.config.XmlConfig2"
                      On="install"
                      Action="..."
                      File="[INSTALLDIR]\Dynamics.exe.config"
                      ...
                      />
    </Component>
    

    【讨论】:

      猜你喜欢
      • 2018-11-19
      • 1970-01-01
      • 2012-02-26
      • 2013-08-24
      • 1970-01-01
      • 2013-08-25
      • 2015-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多