NullSoft Installer - 升级应用程序时升级 app.config
我正在使用 NSIS 安装我的应用程序,并尝试提前为将来的更新做好准备。通常,使用 ClickOnce,我可以调用 Upgrade() 方法,通过访问先前安装中的设置来更新用户的设置。不幸的是,当使用 NullSoft 安装程序时,新的配置文件与其他所有内容一起打包,并在安装时覆盖现有配置文件。升级应用程序并将其与新的配置文件合并时,维护用户设置的最有效方法是什么?
到目前为止,我的想法是将用户的配置文件的副本存储在单独的位置,然后在启动时,通过将程序集版本与包含先前程序集版本的配置文件中的设置进行比较来检查应用程序是否已升级。如果应用程序似乎已升级,它将继续以某种方式将旧配置与新配置合并,但我不确定最安全/最有效的方法是什么。
I am using NSIS to install my application and I am trying to prepare ahead of time for future updates. Normally with ClickOnce, I'd be able to call the Upgrade() method to update the user's settings by accessing their settings from the previous installation. Unfortunately, when using the NullSoft Installer the new config file is packaged along with everything else and overwrites the existing one upon installation. What would be the most effective way to maintain a user's settings when upgrading the application and merging them with a new config file?
My idea so far is to store a copy of the user's config file in a separate location and then on startup, check to see if the application has been upgraded by comparing the assembly version with a setting in the config file that contains the previous assembly version. If it appears the application has been upgraded, it would then proceed to somehow merge the old config with the new one, but I am not sure what would be the safest/most effective way to do this.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的安全升级策略是仅将新 xml 文件中的新元素和属性添加到原始文件中。但是,我不会复制新的 xml 文件,而是会在 CSV 中获得 xpath 和值的列表,程序将在启动时检查这些列表并根据其配置文件执行。
My strategy for a safe upgrade would be to only add new elements and attributes from the new xml file to the original one. However, rather than copy the new xml file, I would have a list of xpaths and values in a CSV that the program would check for on startup and execute against its config file.