It would take some logic in a few areas but it should be doable, assuming that you're talking about some general appSettings/ConnectionString/etc items that would have known default values. (if this includes custom runtime bindings that you wouldnt necessarily know about or similar you'd need to have a custom action do a deeper file comparison and the following won't work)
If we have a WEBCONFIG.OPERATION property we can set one of 3 values "Merge", "Overwrite", "Ignore" and then change as necessary for user selection.
Merge will write the config and update it with the user values we search out
Overwrite will write the default config file only
Ignore will do nothing about the file
We need a property for each item you expect to have user configuration applied to it. It should be defaulted to the expected default value, so you can compare against it.
You will need the web.config installed as a standard file (not as an XML file write), the web.config itself should be in the default state that you want it to be for the "overwrite" case (its still modifiable in an XML update BTW). In the properties of the web.config file install goto Operations tab and select
Do not overwrite existing file with the condition
This condition tells the MSI to overwrite in all cases except when WEBCONFIG.OPERATION is "Ignore".
To doubly ensure that the file is written (which is important for the XML update to execute) we can goto the component for the web.config (make sure its alone in its component) and set the component condition to
Code: Select all
NOT (WEBCONFIG.OPERATION = "Ignore")
This condition tells the MSI to install the component (which will get a new item momentarily) anytime WEBCONFIG.OPERATION is "NOT Ignore".
Now we need to merge any updates, which we can do with an XML write/update. Right click in the folder for web.config and select New XML file and in this xml write/update enter all the XML sections that would be merged in (appSettings, etc). You'll have to manually name the file to web.config, then goto its component and make sure its in with the actual web.config file write.
Lastly we need a search in the web.config to pull out all those configuration options, this would be just a normal XML search.
You can now compare the search results to expected defaults and ask the user if necessary.
I've whipped up an (untested) AIP file that I believe should do the trick since its probably hard to follow in text! Its a real basic example. and you should if implementing it make things more robust (separate UI properties, case sensitivity checks, etc, etc) but I think should work as I expect