如果 WiX 中不存在则复制 [英] Copy if not exist in WiX

查看:46
本文介绍了如果 WiX 中不存在则复制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个配置文件 myapp.exe.config,我只想在它不存在时安装.也就是说,我不想覆盖任何现有的配置文件.如何在 WiX 中做到这一点?

I have a config file, myapp.exe.config, that I want to install only if it does not already exist. That is, I don't want to overwrite any existing config file. How can this be done in WiX?

(最终,我将不得不对设置做一些更复杂的事情,具有默认值和覆盖等.但与此同时,我只是在寻找短期修复.)

(Ultimately I will have to do something more sophisticated with settings, having defaults and overrides and so on. But in the meantime I am just looking for a short-term fix.)

推荐答案

如果文件是 keypath.例如,如果 foo.config 已经存在(或者在版本化文件的情况下,如果已经存在具有相同或更高版本号的文件),则不会安装以下组件:

What you describe is the default behavior if the file is the keypath of a component. For example, the following component will not be installed if foo.config already exists (or in the case of a versioned file, if a file with a equal or higher version number already exists):

<Component Id="foo.config">
   <File Source="foo.config"/>
</Component>

请注意,如果您的组件中有多个文件,那么只有一个可以是关键路径.您可以通过将文件的 KeyPath 属性设置为 yes 来控制这一点.但推荐的策略是每个组件只有一个文件,在这种情况下,该文件会自动成为组件 keypath.

Note that if you have multiple files in your component, then only one can be the keypath. You can control this by setting the KeyPath attribute of the file to yes. But the recommended strategy is to have only one file per component, in which case the file automatically becomes the component keypath.

编辑:请注意,可以使用 REINSTALLMODE 属性.您可能想使用 orca 打开您的 MSI并查看是否在属性表中设置了此属性.

edit: note that this default behavior can be overridden with the REINSTALLMODE property. You may want to open your MSI with orca and see if this property is being set in the property table.

这篇关于如果 WiX 中不存在则复制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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