Having WiX upgrade a config file with missing items

丶灬走出姿态 提交于 2019-12-07 21:50:36

问题


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?


回答1:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!