简体   繁体   中英

Having WiX upgrade a config file with missing items

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...]

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.

Is this possible?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM