0

I'm building a setup for a web application using Windows Installer XML. Most of the files are gathered using the heat tool within a custom build file. This includes the Web.config which is modified at install-time.

Is there any way to prevent this file from being overwritten if it exists - for example if I'm running an update?

Revoluzifer
  • 323
  • 4
  • 14
  • possible duplicate of [Copy if not exist in WiX](http://stackoverflow.com/questions/1912037/copy-if-not-exist-in-wix) – Erti-Chris Eelmaa May 22 '14 at 19:38
  • No, this is not a duplicate or at least the answer given in: [link](http://stackoverflow.com/questions/1912037/copy-if-not-exist-in-wix) does not fit my needs. I cannot provide a version number per file because I'm using heat to gather those files. – Revoluzifer May 27 '14 at 13:29

1 Answers1

2

If the MSI installs the config file and then a custom action or an app modifies it then it won't be replaced on an update because of the file overwrite rules.

It will be removed if you uninstall it, and that includes a major upgrade that has RemoveExistingProducts early in the upgrade.

When MSI installs data files it sets creation date and modify date to be the same so that it can detect if the file has been modified after it has been installed on the system. Modifying the web.config file during the install (presumably after MSI has put it on the system) is code that modifies the file. This stuff is easy to test. Install a data file with MSI and examine the dates, then modify it and examine the dates again. Similarly, after your install look at the modify and create dates of the config file - they should be different and so an MSI update won't replace it as described before.

PhilDW
  • 20,260
  • 1
  • 18
  • 28
  • The file is not being modified by a custom action or another app. Web.config modification happens within a component using WiX's XmlFile element. Again, my steps are: Harvest published webfiles using heat; Modify web.config using WixUtilExtension:XmlFile element. – Revoluzifer May 27 '14 at 13:27
  • In this context "another app" is any code that alters the data file after it has been put on the system, including WiX-supplied Xml Updates. See if the updated explanation helps. – PhilDW May 28 '14 at 16:32