如果 WiX 中不存在则复制

发布于 2024-08-14 20:56:41 字数 141 浏览 2 评论 0原文

我有一个配置文件 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.)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

2024-08-21 20:56:41

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

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

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

编辑:请注意,可以使用 REINSTALLMODE 属性。您可能需要使用 orca 打开 MSI并查看属性表中是否设置了该属性。

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>

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.

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.

屋檐 2024-08-21 20:56:41

您想在组件上使用 NeverOverwrite 和 Permanent...

<Component Id="foo.config.cmp" NeverOverwrite="yes" Permanent="yes" Guid="INSERT_GUID_HERE">
    <File Id="foo.config.file" KeyPath="yes" Source="foo.config"/>
</Component>

我在 config.json 文件上使用它,其中包含非常长的令人讨厌的 Web 服务连接字符串。它永远不应该被任何用户操作清空,并且在卸载后停留在后面。

http://wixtoolset.org/documentation/manual/v3/xsd/ wix/component.html

You want to use NeverOverwrite and Permanent on the component...

<Component Id="foo.config.cmp" NeverOverwrite="yes" Permanent="yes" Guid="INSERT_GUID_HERE">
    <File Id="foo.config.file" KeyPath="yes" Source="foo.config"/>
</Component>

I use this on my config.json files that contain really long nasty connection strings to a web service. It should never be blanked out by any user action and linger behind after an uninstall.

http://wixtoolset.org/documentation/manual/v3/xsd/wix/component.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文