Search defaults to first folder matching [APPDIR] - Advanced Installer Community
Adam Jensen666
Posts: 5
Joined: Fri Oct 03, 2014 1:31 pm

Search defaults to first folder matching [APPDIR]

Hello,

I have an issue with search defaulting to first folder matching [APPDIR] when I am actually trying to get something from the actual installation folder.

I have a file search that targets a config file with [APPDIR] as the path and depth set to 2. This is set in Directory properties window that opens when the child element of the file search is selected.

Now in environments where multiple folders that start with [APPDIR] are found, the search defaults to first.

Example:

[APPDIR] = [WindowsVolume][ProductName] is set in our installer.

Folders that exist in environment where we're installing:

c:\product <- this is a left over from uninstalled version of the product and contains config file with the same name as the actual installation
c:\product2 <- this is the currently installed product.

Now in a situation where I'm upgrading installation that is located in c:\product2 the search will find the xml file from under c:\product. This is very bad.

How can I get the correct config file from the search?

It is weird that in install dialogs the [APPDIR] is shown as c:\product2 but when searching we get matches from c:\product!
Dan
Posts: 4530
Joined: Wed Apr 24, 2013 3:51 pm

Re: Search defaults to first folder matching [APPDIR]

Hello and welcome to Advanced Installer,

First of all, if in in environments where multiple folders that start with [APPDIR] are found, the search will default to first, because this is the behavior of windows installer searches.

The searches are executed before the APPDIR property is set. So you need to enter in the Directory properties window the same path of installation that is entered in
Install Parameters->Application Folder field and Depth=0.
APPDIR is also set to this path, but as I said after the searches are performed.

Hope this is helpful to you.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Adam Jensen666
Posts: 5
Joined: Fri Oct 03, 2014 1:31 pm

Re: Search defaults to first folder matching [APPDIR]

Dan wrote: First of all, if in in environments where multiple folders that start with [APPDIR] are found, the search will default to first, because this is the behavior of windows installer searches.
Okay, I probably should have known this, but it's nice to know anyway.
Dan wrote: The searches are executed before the APPDIR property is set. So you need to enter in the Directory properties window the same path of installation that is entered in
Install Parameters->Application Folder field and Depth=0.
APPDIR is also set to this path, but as I said after the searches are performed.
Well, this doesn't change the situation one bit, because Install Parameters->Application Folder has value [WindowsVolume][ProductName] (eg. c:\product) thus it is not the installation folder for upgrade and I'm guessing, that while upgrading, the actual installation folder is resolved at some point and set to [APPDIR]. So, basically all custom searches to the [APPDIR] folder are useless if there happens to be an old folder that matches [ProductName] and the actual file we are looking for happens to exist inside?

Are there any known work-arounds? How does the AI come up with the correct installation folder without any user input?

I guess if there are no other options we'll just need to get rid of those config files on uninstall. Does the uninstall make backups on uninstall too if I set AI to make backups when updating?
Adam Jensen666
Posts: 5
Joined: Fri Oct 03, 2014 1:31 pm

Re: Search defaults to first folder matching [APPDIR]

Adam Jensen666 wrote:Does the uninstall make backups on uninstall too if I set AI to make backups when updating?
Just read http://www.advancedinstaller.com/user-g ... stall.html and seems that backups are done on uninstall when "Create backup on updating" is enabled. Can you confirm? This might solve my problem.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Search defaults to first folder matching [APPDIR]

Hello,
Well, this doesn't change the situation one bit, because Install Parameters->Application Folder has value [WindowsVolume][ProductName] (eg. c:\product) thus it is not the installation folder for upgrade and I'm guessing, that while upgrading, the actual installation folder is resolved at some point and set to [APPDIR]. So, basically all custom searches to the [APPDIR] folder are useless if there happens to be an old folder that matches [ProductName] and the actual file we are looking for happens to exist inside?
I am afraid I do not fully understand your scenario. Can you please send us the aip (project file) and a concrete test case with explained steps at support at advancedinstaller dot com so we can investigate this?
I guess if there are no other options we'll just need to get rid of those config files on uninstall. Does the uninstall make backups on uninstall too if I set AI to make backups when updating?
In order to achieve this you can use a file removal operation. From the "Files And Folders" page add a file removal operation for the configuration file and set it to be executed on component uninstall.
Just read http://www.advancedinstaller.com/user-g ... stall.html and seems that backups are done on uninstall when "Create backup on updating" is enabled. Can you confirm? This might solve my problem.
I am not sure if unchecking this option would help you, but you can try it. Our "XML updates" support creates indeed backup files (usually with .back extension) when an XML file is updated on install/uninstall.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Adam Jensen666
Posts: 5
Joined: Fri Oct 03, 2014 1:31 pm

Re: Search defaults to first folder matching [APPDIR]

Since I couldn't figure out if there is a proper way to achieve what I want installer to do and what it is, I build a following solution.

1. Use custom command line script to back up configuration files during uninstall before they're removed. Make sure you put them in a new folder, since installer will eat folders where all the stuff is made by itself.
2. Delete all configuration files in uninstall.
3. ???
4. Profit in subsequent upgrades after new install, since wrong stuff won't be picked up from the (now deleted) old configuration files that still existed (previously) in folders where the installer searches might magically pick them up from.

Sorry for not escalating the installer project to AI support (we have these ugly policies for not sharing business secrets to 3rd parties) or explaining the situation in more detail, since I got it working now.

Thank you.
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Search defaults to first folder matching [APPDIR]

You're welcome Adam. I'm glad you got this working.

If there would be anything we can help you with just let us know.

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

Return to “Building Installers”