elou
Posts: 96
Joined: Tue Apr 14, 2015 9:12 am

Update schould advice before overwritting files

Hello,
I've got a web-site which should be updated per installer.
Files such web.config may have been modified by the user.
I would like the wizzard to detect that such files have been modified by the user and prompt him if I should overwrite his changes, merge his changes or take his changes.
Is there any facility in Advanced Installer to achieve that goal?

Regards,
Éric.
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Update schould advice before overwritting files

Hi Éric,

I'm afraid that the Updater/installer cannot detect and prompt to the user if a file was modified. But when you add the files to the installer, you can set some files not to be overwritten. This can be done from the "Files and Folders" page, by going to the "Properties -> Operations" tab.

Let me know if this helped, otherwise give me more details about your scenario.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
korr
Posts: 48
Joined: Tue Sep 09, 2014 3:13 pm

Re: Update schould advice before overwritting files

It would take some logic in a few areas but it should be doable, assuming that you're talking about some general appSettings/ConnectionString/etc items that would have known default values. (if this includes custom runtime bindings that you wouldnt necessarily know about or similar you'd need to have a custom action do a deeper file comparison and the following won't work)

If we have a WEBCONFIG.OPERATION property we can set one of 3 values "Merge", "Overwrite", "Ignore" and then change as necessary for user selection.
Merge will write the config and update it with the user values we search out
Overwrite will write the default config file only
Ignore will do nothing about the file

We need a property for each item you expect to have user configuration applied to it. It should be defaulted to the expected default value, so you can compare against it.

You will need the web.config installed as a standard file (not as an XML file write), the web.config itself should be in the default state that you want it to be for the "overwrite" case (its still modifiable in an XML update BTW). In the properties of the web.config file install goto Operations tab and select Do not overwrite existing file with the condition

Code: Select all

WEBCONFIG.OPERATION = "Ignore"
This condition tells the MSI to overwrite in all cases except when WEBCONFIG.OPERATION is "Ignore".

To doubly ensure that the file is written (which is important for the XML update to execute) we can goto the component for the web.config (make sure its alone in its component) and set the component condition to

Code: Select all

NOT (WEBCONFIG.OPERATION = "Ignore")
This condition tells the MSI to install the component (which will get a new item momentarily) anytime WEBCONFIG.OPERATION is "NOT Ignore".

Now we need to merge any updates, which we can do with an XML write/update. Right click in the folder for web.config and select New XML file and in this xml write/update enter all the XML sections that would be merged in (appSettings, etc). You'll have to manually name the file to web.config, then goto its component and make sure its in with the actual web.config file write.

Lastly we need a search in the web.config to pull out all those configuration options, this would be just a normal XML search.

You can now compare the search results to expected defaults and ask the user if necessary.


I've whipped up an (untested) AIP file that I believe should do the trick since its probably hard to follow in text! Its a real basic example. and you should if implementing it make things more robust (separate UI properties, case sensitivity checks, etc, etc) but I think should work as I expect
Attachments
XML Dance.zip
(5.66 KiB) Downloaded 275 times
Eusebiu
Posts: 4931
Joined: Wed Nov 14, 2012 2:04 pm

Re: Update schould advice before overwritting files

Hi korr,

Thank you for the detailed example and for the time you invested in writing it. I'm sure it will be helpful for the users that need to preserve their settings.

Best regards,
Eusebiu
Eusebiu Aria - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”