让WiX升级缺少项目的配置文件 [英] Having WiX upgrade a config file with missing items

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

问题描述

我刚刚开始将WiX用作现有应用程序的安装框架。该应用程序具有一个App.Config文件,该文件控制各种特定于客户的设置。这些设置大部分是在内部修改的,并且不是用户可控制的。

I am just starting to use WiX as my installation framework for my existing application. The application has an App.Config file that controls various customer-specific settings. The majority of these settings are modified in-house, and are not user-controllable.

此类配置文件的示例为:

An example of such a config file would be:

[...snip]
<applicationSettings>
    <setting name="DatabaseConnectionString" serializeAs="String">
        <value>Data Source=localhost;Initial Catalog=CustomersDatabase;Persist Security Info=True;Integrated Security=True</value>
    </setting>
</applicationSettings>
[snip...]

发布较新版本的应用程序时,将有一个库存配置文件,其中包括任何新的应用程序设置:

When a newer version of the application is delivered, it will have a stock configuation file, which includes any new app settings:

[...snip]
<applicationSettings>
    <setting name="DatabaseConnectionString" serializeAs="String">
        <value>Data Source=localhost;Initial Catalog=NonProductionDatabase;Persist Security Info=True;Integrated Security=True</value>
    </setting>
    <setting name="NewConfigItem" serializeAs="String">
        <value>ConfigDetails</value>
    </setting>
</applicationSettings>
[snip...]

我想将WiX安装程序安装到升级时,创建一个合并的App.Config,以使现有设置保持不变,但是将使用其默认值插入新的配置项:

I would like to setup my WiX installer to, during an upgrade, create a merged App.Config, such that the existing settings are untouched, but that new config items are inserted with their default values:

[...snip]
<applicationSettings>
    <setting name="DatabaseConnectionString" serializeAs="String">
        <value>Data Source=localhost;Initial Catalog=CustomersDatabase;Persist Security Info=True;Integrated Security=True</value>
    </setting>
    <setting name="NewConfigItem" serializeAs="String">
        <value>ConfigDetails</value>
    </setting>
</applicationSettings>
[snip...]

但是,我不希望安装程序必须事先知道什么是配置选项;我只是希望它扫描现有文件,并从安装程序中添加新选项(如果发现任何丢失的话)。

However, I do not want the installer to have to know beforehand what the configuration options are; I simply want it to scan the existing file, and add new options from the installer if any are found missing.

这可能吗?

推荐答案

是的,您需要编写一个自定义操作来读取现有的xml文件。然后,我建议根据读取的数据,以在此问题中所述的形式向XmlConfig表添加临时记录。

Yes, you'll need to write a custom action to read the existing xml file. I would then recommend adding temporary records to the XmlConfig table as described in this question based on the read data.

这篇关于让WiX升级缺少项目的配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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