使用 WiX 管理配置文件 [英] Manage configuration files with WiX

查看:32
本文介绍了使用 WiX 管理配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中包含多个文件,其中包含配置参数和其他数据,这些数据会随着用户使用该应用程序而发生变化.这些文件可以随着我的软件的更新版本而改变,但用户也可以修改它们(或者它们可能被应用程序本身更改).基本上,我正在寻找一种解决方案来防止用户对这些文件的更改被覆盖,但同时也是一种在用户升级我的软件时安装可能更新的文件的方法.

I have an application with several files that contain configuration parameters and other data that changes as the user uses the application. These files can change with newer versions of my software, but the user can also modify them (or they may be changed by the application itself). Basically, I'm looking for a solution to prevent the users' changes to these files from being overwritten but also a way to install the potentially updated files when the user upgrades my software.

在 *NIX 上使用 RPM,您可以使用 %config 函数将文件定义为配置文件,然后 RPM 将重命名现有文件(如果存在)并在升级时安装新文件(可能不理想,但是对于 WiX,我可以忍受这样的事情).

With RPM on *NIX you could use the %config function to define a file as a configuration file and RPM would then rename the existing file (if it existed) and install the new one on an upgrade (maybe not ideal, but I could live with something like this for WiX).

我想将我的配置文件安装到一个子目录甚至不同的名称(例如 default.cfg),然后使用 WiX 中的 元素将文件复制到它们的正确的位置.这样,默认文件将在安装时删除并在升级时覆盖,但实际用户文件将保持不变.不幸的是,对于 ,Windows Installer 仍然希望管理(和删除)目标文件.

I'd like to install my config files to a subdirectory or even a different name (e.g. default.cfg) and then use the <CopyFile> element in WiX to copy the files to their correct locations. This way, the default files would get removed on install and overwritten on an upgrade, but the actual user files would stay the same. Unfortunately with <CopyFile>, Windows Installer still wants to manage (and remove) the destination file.

我还考虑过在 WixUtilExtension 中使用 QtExec 操作来基本上执行复制 default.cfg reallocation.cfg",但这不太好用,而且有点麻烦.

I've also considered using the QtExec action in WixUtilExtension to basically do "copy default.cfg reallocation.cfg" but this wouldn't quite work and it is a bit of a hack.

处理这个问题的正确方法是什么?

What is the correct way to handle this?

推荐答案

我的建议通常是将用户可编辑的内容放在一个单独的文件中,并通过应用程序而不是安装进行管理.这也意味着单独的文件是用户内容",应该被排除在安装之外.

My recommendation is usually to have the user editable content in a separate file and manage that via the application instead of the install. That also means the separate file is "user content" and should be left out of the install.

我发现尝试以声明方式迁移用户数据非常困难.当您需要考虑安装、卸载、修复、修补和回滚所有这些情况时,尝试在设置时执行此操作只会使情况变得更糟.

I've found trying to do migration of user data declaratively to be deceptively difficult. Trying to do it at setup time when you need to think through install, uninstall, repair, patching and rollback for all of those cases only makes it worse.

例如,RPM 行为对修复"有何作用.把用户数据复制出去,换成好的文件?这可能在 60% - 80% 的情况下是正确的.和卸载,应该删除文件吗?如果用户只是升级到下一个版本,那就很棘手了.

For example, what does the RPM behavior do on "repair". Copy the user data out of the way and replace it with a good file? That's probably correct 60% - 80% of the time. And uninstall, should the file be removed? That's tricky if the user is going to just upgrade to the next version.

同样,最好让他们决定如何调整配置.恕我直言.

Again, better to let them decide what to do with their tweaks to the configuration. IMHO.

这篇关于使用 WiX 管理配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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