1

What is the standard way to handle web.config files during major upgrade.I'm aware how the unversioned files are handled during upgrade,the file will not be replaced if the file has been modified by the user.

Is there a way to deal with the scenario where in there are new entries added to config file bundled with the latest installer that needs to be installed,and also retain the existing entries modified by the user during major upgrade in Wix.

Santhosh
  • 671
  • 12
  • 36
  • How are you sequencing RemoveExistingProducts? See https://msdn.microsoft.com/en-us/library/aa371197%28VS.85%29.aspx?f=255&MSPPError=-2147217396. Also plenty good SO posts on this topic such as https://stackoverflow.com/questions/2441651/wix-overwrites-config-files-during-setup-how-can-i-avoid-this – Ritmo2k Mar 06 '18 at 13:29
  • MSI was designed in the 90s prior to XML files. It's a fundamental lacking of the Default File Versioning rules because XML files are not just a file they are like an entire registry hive. You have to keep your application data and configuration data different so that it's very clear what the installer should and shouldn't overwrite. I usually discuss this as part of intake for a new client. The best way to win this game is to not play the game. – Christopher Painter Mar 07 '18 at 01:37

4 Answers4

1

The simple solution that a lot of my customers have liked is to not put user data in the web.config. Instead we use the AppSettings@file and ConnectionStrings@ConfigSource elements to specify an override file and keep the user data there. What MSI doesn't know about it won't tamper with. Now you don't have to be an MSI component rules wizard.

https://msdn.microsoft.com/en-us/library/ms228154(v=vs.85).aspx

https://msdn.microsoft.com/en-us/library/system.configuration.sectioninformation.configsource(v=vs.100).aspx

Christopher Painter
  • 54,556
  • 6
  • 63
  • 100
1

I know the question is for Wix, but just wanted to point out how much time commercial tools can save in such scenarios.

For example, using Advanced Installer you can read and load into an MSI property any XML values and then use the XML Files updater to write dynamic content in the files, at install(upgrade) time. (check the videos at the end of each article for a quicker overview)

Disclaimer: I work on the team building Advanced Installer.

Bogdan Mitrache
  • 10,536
  • 19
  • 34
0

Set the component to always overwrite and write a custom action to add the needed information to the config file.

Doc
  • 698
  • 3
  • 16
  • How does that accommodate post install user defined settings? – Ritmo2k Mar 06 '18 at 13:28
  • The user defined settings can be prompted for or read from the previous config file then stored in properties. Since you're after the InstallFinalize you'll have to store them so that they're available outside – Doc Mar 06 '18 at 23:50
0

The only way that seems possible is a custom action to merge the entries in the new file into the existing file, because you want data from the existing a new files. You would also need the upgrade scheduled late (after InstallExecute) so that the upgrade isn't an uninstall of the old product followed by an install of the new product.

If you are doing an upgrade (the WIX_UPGRADE_DETECTED property will be set by a MajorUpgrade element), so update the existing file, otherwise install the new one.

There might be a way to express the updates as an Xml transform, so something in the WiX util:xml tools might help do an update.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • It just doesn't scale. The MSI would have to have knowledge of the v1 base XML to calculate the transform and then apply it to the v2 base XML after it's installed. A real nightmare. The easiest solution is don't let users modify files owned by the installer. Store that data in a file the installer doesn't know about. – Christopher Painter Mar 07 '18 at 01:47