Editing xml files with Advanced Installer

As part of my #learn365 today I will post a new feature I've learned about the Advanced Installer application. Advanced Installer, for those who never heard it before, is equivalent to InstallShield and allows users to create powerful custom installers for a variety of apps. So today’s lesson is:

How to edit xml files and keep them up-to-date with the repo.

The problem in my scenario is that I have to edit the sql connection strings in all the app and web config files using the values supplied by the user during the installation. There are a number of ways to tackle this apparently not so trivial issue:

1)      Import the xml files in the installer as proper xml files and edit the nodes using the "xml editor dialog"

2)      Use the "text file update" option and perform a search and replace operation for the values in question

3)      Create and call a custom dll or batch file to perform the search and replace in the files in question

Each approach comes with its pros and cons.

The first option allows the user to properly parse the xml in the installer and then pass variable values to the necessary xml elements. Although this option is very powerful it, unfortunately, removes the link between the source file and the end result. If the config changes inside the solution/repo, these changes will not be propagated to the installer and hence the file will be out-of-date.

The second approach is easier to implement and has a number of powerful features, like the use of regular expressions in the search. However, it requires that the properties being replaced are not changed in any way in the solution/repo or this will break the whole functionality.

The third approach is similar to the second one, but in this case the fact that we can use a dll allows us to take full control of the changes and be more flexible. The disadvantage of this option is the time and effort required to write and test the code.

In my case, I went ahead with option 2 and I managed to get 4 files imported and edited in a matter of minutes. More details on how to use this functionality can be found here.

Happy coding…


  • Share this post on