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.
来源:https://stackoverflow.com/questions/15981685/having-wix-upgrade-a-config-file-with-missing-items