Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

How to upgrade file with type "XML File (Windows Installer)

Dear Advanced Installer Support Team,

Our goal is to install some config files (xml) on the customer´s PC. We change those config files from time to time by adding/removing some nodes. There are some special nodes too like username, password which will be set by the customer. Obviously their settings are always overwritten by our update packs since currently we just added the config files to the .aip project with the type of "XML Configuration File". In addition we use "Always overwrite existing file" options, because we would like our latest changes to take to the customer´s PC.

How could we achive the following:
1. Always install our latest config xml file on the customer´s PC.
2. BUT keep some of the nodes (e.g. username, password) untouched.

We know you have the file type of "XML File (Windows Installer) too. Adding our xml by selecting the checkbox and then disabling the option of "IF the element is fonud -> Update" works just fine and the relevant nodes won't be overwritten. Our only problem with this approach is that "XML File (Windows Installer)" files does not show the changes we do in the physical XML file on the disk.

For example:
1. We add the file C:/test.xml to our .aip as a "XML File (Windows Installer)" file
2. We disable the update mechanism for some nodes so username and password won't be overwritten on the customer's PC.
3. We modify C:/test.xml in a later version of our product. The "XML File (Windows Installer)" file in the .aip won't contain the new nodes, so they will be missing from the customer's PC after they install the later version of our product. This is an issue

Could you please advise us something?

Best regards,
Zsolt
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to upgrade file with type "XML File (Windows Installer)

Hi Zsolt,

After testing your scenario we have attached a sample project with the solution we found.

The first thing you have to do is create an external base XML File with the node structure that you want to have. Add it to your project but not as a "XML File (Windows Installer)".
Next up you have to create a XML file from Advanced Installer. For this, you can go to the Files and Folders page and on the ribbon click "New XML file". Make sure that both your XML files have the same name and ignore the conflict message.

Inside the Files and Folders page, double click the Advanced Installer XML. Recreate the structure used in the base XML but include only the essential nodes that will lead to your Username and Password nodes including these as well.
For every node in this structure except Username and Password disable the "If element is found option" option from the XML Element Settings Tab while for Username and Password make sure it is enabled and set to "Update" -->"First Matching".
Please note that with each install and uninstall, some XML backup files will appear. In order to not clog the user's machine, in the the Advanced Installer XML file option, go to Install --> Error Policy and disable the "Create backup before updating" option from the XML File Install Tab.

In the example we created, Username and Password have their own atributes with their respective names.Since you want your user to provide the data for these we will link each attribute to contain the values of the next two properties "[USERNAME_PROP]","[PASSWORD_PROP]" linked to two edit boxes in a dialog.
You might want the dialog containing the edit boxes to prompt the user on a first install and not on an upgrade. For this go to the Dialogs page, select the dialog that contains the edit boxes then right click it. From the context menu chose "Show only if" and set the condition to "NOT OLDPRODUCTS".

OLDPRODUCTS - this property is set in the upgrading MSI if the package found an older version installed on the target machine.

In order to store the values provided by the user to be available with each upgrade of your product. Go to the Search page and create a "New XML Search" with the same structure as the Advanced Installer XML.
For the File Path simply set it to [APPDIR] and the path to your XML file. Here is an example "[APPDIR]New file.xml" . Underneath the "File Path", go to Username in the XML structure and "Add..." a search with the following values:
  • Search: Attribute name
  • Value: Username
Check the store checkbox --> Atribute Value in USERNAME_PROP

Do the same for Password.
  • Search: Attribute name
  • Value: Password
Check the store checkbox --> Atribute Value in PASSWORD_PROP

For these searches to work though you will have to change a sequence in the Table Editor page. Once there go to the InstallUISequesnce and InstallExecuteSequence and set the "AI_XmlLocator" action to be after "SET_APPDIR" and "SET_SHORTCUTDIR" actions, in our case it was 776.

Now with every upgrade your Username and Password nodes will be created if they do not exist and their data stored safely for future use.

Best regards,
Dan
Attachments
How to upgrade file with type XML File.rar
(4.84 KiB) Downloaded 279 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

Re: How to upgrade file with type "XML File (Windows Installer)

Hi Dan,

Thanks for the comprehensive answer, I´ll try out all your suggestions. May I ask you where can I find the sample project you were talking about? I think you forgot to attach it.

Best regards,
Zsolt
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to upgrade file with type "XML File (Windows Installer)

Hi Zsolt,

Indeed, it seems that I forgot to attach it. Please see below.

Best regards,
Dan
Attachments
How to upgrade file with type XML File.rar
(4.84 KiB) Downloaded 279 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

Re: How to upgrade file with type "XML File (Windows Installer)

Hi Dan,

There is a little bit of misunderstanding here, sorry if I was unclear. Basically we don't want to ask the customer to define username and password every time he installs a newer version of our product.

We assume
1. He installed an earlier version of our product already, manually opened our web.config file via a text editor and defined his username and password already.
2. Now he is about to install the latest version of our product which already contains several changes for the web.config file. Some nodes have been removed some others have been added. We'd like to take all these changes to the end PC, it means we'd like to remove and add some nodes BUT keep username and password nodes untouched.

Could you please consider this scenario?

Thanks in advance!

Best regards,
Zsolt
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to upgrade file with type "XML File (Windows Installer)

Hello Zsolt,

Please note that the user has to provide the Username and Password only on the first install. If it is an upgrade, the "NOT OLDPRODUCTS" condition will detect that and the related dialog will not be displayed. However, this was just an example to get the user input. You can remove this entirely if the nodes get defined in the XML another way. The passing between the two XML's functionality is not dependent on the user input.

So long as the searches find the nodes, they will take their data and depending on the case, create or update them. You can do whatever changes you want to the base XML file.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

Re: How to upgrade file with type "XML File (Windows Installer)

Hi Dan,

Indeed, your sample is working fine in some case but not in every case. Your sample project successfully read out the username and password from APPDIR\New file.xml and preserved those data.

The problem is that we are not able to replicate this behaviour with files under "IIS WWW Root" location. In our real life .aip project we´d like to preserve some web.config files under "IIS WWW Root".

In order to explain this better, I extended your sample project, please find it attached. You can see 2 new files under "IIS WWW Root", those files won´t keep their username and password nodes.

Repro:
1. Build version 11.0.0
2. Install it on a PC
3. Search for the 3 new files and put some values into their username and password nodes.
4. Build version 11.1.0 as major. For a more realistic scenario, please modify the 3 physical files a bit (e.g. rename a node, change the default username, pass).
5. Install 11.1.0 on the PC
6. Confirm that "New file.xml" under Program Files kept his username and password values BUT "New file 2.conf" and "New file 3.xml" have lost their credentials.

Should we change something else in the sample project to make it working?

Best regards,
Zsolt
Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

Re: How to upgrade file with type "XML File (Windows Installer)

The new sample project.
Attachments
How to upgrade file with type XML File _ new version.zip
(5.6 KiB) Downloaded 268 times
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to upgrade file with type "XML File (Windows Installer)

Hello Zsolt,

Please note that for your searches you are using the [TEST_Dir] property PATH assigned to the TEST folder. The path of the TEST folder is resolved by the Windows Installer during the Cost Finalize action. However, the searches are executed by the AppSearch action, which is executed before the Cost Finalize.

To overcome this behavior, you can add a reference to "IIS WWW Root" folder which has the identifier "IIsWWWRootFolder". The "IIS WWW Root" folder is resolved by the Ai_ResolveKnownFolders action, before the AppSearch.

So, you should have something like that in the search filed:

Code: Select all

[IIsWWWRootFolder]TEST\New file 2.config.
I have attached a sample with this modification.

Best regards,
Dan
Attachments
How to upgrade file with type XML File _ new version.rar
(5.24 KiB) Downloaded 262 times
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

Re: How to upgrade file with type "XML File (Windows Installer)

HI Dan,

Thanks for the tip, it seems to be working.

Best regards,
Zsolt
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: How to upgrade file with type "XML File (Windows Installer)

That's great news Zsolt,

Please let me know if there is anything else I can help you with.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

Re: How to upgrade file with type "XML File (Windows Installer)

Hi Dan,

There is one more scenario you could help me please:
1. We publish version 1.0 of our product with a config file in it. The file has a lot of pre-configured nodes which are commented out by default.
2. The customer installs 1.0 and might uncomment some of the nodes depending on his needs. He might slightly change the content of those nodes as well.
3. Product version 2.0 will contain a refreshed config file with more/less commented nodes.
4. The customer installs 2.0. The nodes he uncommented and changed should be kept. The rest of the nodes should be coming from the config file released by product version 2.0.

As far as I can see this scenario cannot be solved by the current version of Advanced Installer since "Comment" nodes does not have the same settings (Element settings, Install section, Attributes tab etc.) what the other nodes have. Could you please advise us something how to solve this problem? Most of our config files should work based on this scenario.

Best regards,
Zsolt
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: How to upgrade file with type "XML File (Windows Installer)

Hello Zsolt,

I'm afraid we do not have support for your last requirement nor any workaround solution for this.

Basically you need to install XML elements based on a very custom made algorithm. The only way to achieve this will be through your own custom action to analyze the XML file from disk at install time against the one from the setup package and decide which content to update or not, however I'm not even sure this is programmatically possible.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Zsolt Kollarits
Posts: 342
Joined: Fri May 29, 2015 10:36 am

Re: How to upgrade file with type "XML File (Windows Installer)

Hi Daniel,

Probably we could figure out a solution if Advanced Installer would have the usual settings (Element settings, Install section, Attributes tab etc.) for Comment sections too. Then we could prevent the comment from being re-added once more if it is already there.

Best regards,
Zsolt
Daniel
Posts: 8238
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: How to upgrade file with type "XML File (Windows Installer)

Hello Zsolt,

I'm not sure if this will help you or not but starting with our next version of Advanced Installer (14.6) our application includes an improvement and the comments already existing on file from disk on target machine at install time won't be duplicated anymore.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”