2

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?

Greenknight
  • 203
  • 2
  • 8

1 Answers1

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.

Community
  • 1
  • 1
Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
  • While I am not scared (ok, maybe a little) of using c++ to add the temporary records via the WcaAddTempRecord() method you mention in the referenced article, I'd prefer to use a managed language. Is there an exsiting .NET library call that can do this operation, or do I have to P/Invoke this library instead? -- Nevermind! Maybe I should read the ENTIRE article before I start knee-jerk asking questions. :) – Greenknight Apr 15 '13 at 15:11
  • The short answer is DTF, also part of the WiX toolset. :) – Rob Mensching Apr 15 '13 at 15:46