amf
Posts: 10
Joined: Fri Aug 28, 2009 7:04 pm

XML merge creating unwanted backups

Tue Jan 31, 2012 3:33 pm

I have an install that is organized into several different builds, which are combinations of one or more features. Several of the features must modify the web.config file to add in assemblies and web services, but only if the feature is included (because the feature includes a one or more DLLs referenced by the assemblies/services being added). Doing the merge worked fine, just have each one in a separate subdirectory of the main web directory with the "Install folder content into parent folder" checkbox set on the directory.

The problem is that each XML merge being done for the different features was leaving behind an XML backup file that I didn't want the user to see. Clearing the "Create backup before updating" checkbox on the XML Editor's Install tab didn't prevent the backup from being created.

And I also wanted to avoid creating a custom action, just because... well, I'm stubborn.

After much effort with Bogdan, the answer is as follows:

In the directory where the destination web.config is located (not the subdirectories), add a File Removal operation. The name of the operation is web.config*back (we tried web.config.* and that did not work, no idea why). Add the operation to one of the components in a feature that is ALWAYS installed. My builds are comprised of one Main feature along with one or more additional features that modify the web.config file, so I added it to the component of the Main feature that installed my web pages. Set the File Removal to Remove On install and uninstall, because a backup is created for both operations.

I ran the backup, but the files were not removed. Why? Because file removals are -- by default -- done BEFORE the files are installed. The XML merge opertations are done right near the end of the installation, so we have to re-order the operations to run the file removal after the XML merge completes.

Under Custom Actions, there's a menu pick for Show Standard Action. Locate RemoveFiles and click that menu pick to make the file removal action visible. Now right-click the RemoveFiles action and use the Move After menu pick to move it after the InstallExecute action (which is where the files are installed and the XML files are being merged). Do NOT put it after InstallFinalize, because it will fail to complete installation.

And that's it. What you did was create a file removal action to remove the backup files and then you told the installation package to run the file removal after it installs all the executables.

Return to “Common Problems”

 

 

cron