Wix属性评估 [英] Wix property evaluation

查看:22
本文介绍了Wix属性评估的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 FileSearch 结果作为 Component 部分中的条件.我想得到这样的东西:

How to use FileSearch result as condition in Component section. I want to get something like this:

    <Property Id=\"CONFIG_XML_EXISTS\">
        <DirectorySearch Id="CheckForConfigXml" Path="[INSTALLDIR]\">'
           <FileSearch Id="ConfigXmlSearch" Name="config.xml" />
        </DirectorySearch>
    </Property>
    ...
    <Component Id="c_DefaultConfig.xml" Guid="{1AAB0AFD-B763-4A55-8585-B0AD4D8CE23C}">
        <File Id="f_default_config.xml"
              Name="default-config.xml"
              Source="$(var.SourceRoot)\config.xml"/>
        <Condition>CONFIG_XML_EXISTS</Condition>
    </Component>

我不知道为什么但属性 wix 不想评估 CONFIG_XML_EXISTS.

I don't know why but property wix doesn't want to evaluate CONFIG_XML_EXISTS.

推荐答案

因为搜索发生在安装的早期,最可能的原因是 INSTALLDIR 没有价值.您还没有说明您是进行全新安装还是升级,因此不清楚您认为它可能从哪里获得价值.

Because that search happens very early in the install, the most likely reason is that INSTALLDIR has no value. You haven't said whether you're doing a fresh install or an upgrade, so it's not clear where you think it might be getting its value from.

我还要指出,该源代码的目的显然是为了防止安装已经存在的文件,因此:

I'd also point out that the purpose of that source code is apparently to prevent the install of a file if there is one there already, so:

  1. 如果 INSTALLDIR 是安装文件的应用程序文件夹(通常是程序文件),那么用户通常可以更改此位置,因此不清楚该文件将位于您期望的位置.

  1. If INSTALLDIR turns out to be the application folder (typically program files) where your files are installed then users can usually change this location, so it's not clear the file is going to be where you expect it to be.

文件覆盖规则可防止传入文件覆盖修改后的数据文件(修改日期> 创建日期),因此如果该配置文件已更改,则不会被覆盖,您无需进行检查.

The file overwrite rules prevent incoming files from overwriting modified data files (modify date > creation date) so if that config file has been changed it won't be overwritten and you don't need to do the check.

在您的评论中,您说只有在目标(安装)目录中没有此类文件时,我的安装程序才必须创建文件 config.xml.如果存在此类文件,我的安装程序必须创建名为 template.xml 的文件".我认为可能最简单的方法是在安装完成后在应用程序中执行此操作,或者在安装所有文件后在自定义操作中执行此操作.在安装之前似乎没有好的方法可以做到这一点,因为 INSTALLDIR 是不可预测的.我已经看到通过将 XML 文件安装到(比如)用户的应用程序数据解决了这种问题,并且在安装文件之后,应用程序或自定义操作可以查看存在(或不存在)哪些文件并从用户的应用数据.

In your comment you say "My installer must create file config.xml only if there is no such file in target(install) directory. If such file exists, my installer must create file with name template.xml". I think that perhaps the easiest way to do this is in the application after the install has finished, or possibly in a custom action after all the files have been installed. There seems to be no good way to do this before the install because INSTALLDIR is unpredictable. I've seen this kind of problem solved by installing the XML files to (say) User's Application Data, and after the files are installed then the application or a custom action can see what files are there (or not) and get them from User's Application Data.

这篇关于Wix属性评估的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆