Plain project - except for leaving a folder untouched - Advanced Installer Community

We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Plain project - except for leaving a folder untouched

Hello everyone.

I have put together a list of requirements for our product installer, and for some of the items I am looking for reliable solutions:

Requirements:

1) The folder structure and the contents (files and subfolders) to be put into the installer are provided in a specific folder in the filesystem. This folder is being assembled by a script which runs before AI is being run.

1) Two configurations of the software exist, each having different contents in subfolder "db" (except that the db\data dir exists in both), each will result in a different installer:

Configuration 1:

...
APPDIR\bin\db\abc
APPDIR\bin\db\data\ABC1
...

Configuration 2:

...
APPDIR\bin\db\xyz
APPDIR\bin\db\data\XYZ1
...

2) The folder APPDIR\bin\db\data\ must never be touched on updates.

3) The folder APPDIR\bin\db\data\ is going to be extremely large, copying this folder is never an option.

4) The folder APPDIR\bin\db\data\ must be removed at full uninstallation.

5) Files must always be overwritten (except for 2)) file modification dates or version information must be irrelevant.

6) Low/zero maintenance of the installation project when adding, renaming or removing files/folders from the installer ("Files and Folders").

This excludes:

- Configuring individual file attributes manually (error prone: forget to configure -> installer broken).
- Manually adding, renaming or removing files/folders in the installer project (error prone: forget to add, rename, remove in installer project -> installer broken).

However, lightweight scripting (of AdvancedInstaller.com) and lightweight scripted modification of the installer project file are acceptable.

7) Directly after the installer ran through without user visible error (be it for update or new installation) no files or folders may be missing (not the case with file versioning and pending file operations).

8.) If errors occurr a rollback must be performed. In case of new installations the files already placed on disk must be removed (not the case with an ErrorMessage custom action) and the user be informed.



To solve 2) we so far resorted to renaming the data folder to have it under APPDIR\bin\db\data.keep in the installer. Then, after fresh installation, the folder would be renamed to APPDIR\bin\db\data in the installation directory via a custom action. This approach turned out to be problematic because the "data.keep" folder (or any of the files contained in it) can be (and actually were at least once) locked (possibly by anti-virus) for at least 5 seconds (after which our custom action silently gives up), leaving a broken installation behind. (At an update the newly placed "keep.data" folder would not be renamed, but deleted instead.)

To get around the problem of "data.keep" being locked when trying to rename I considered adding the files in that folder into the MoveFile table at runtime in a custom action script, but here lack of documentation seems the problem.


I hope I didn't leave to many things out and that these requirements can be satisfied somehow, with reasonable effort.

Thanks for any answers in advance.



With best regards

Clemens Anhuth
Last edited by canhuth on Wed Sep 17, 2008 10:07 am, edited 1 time in total.
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Plain project - except for leaving a folder untouched

Hi Clemens,
Two configurations of the software exist, each having different contents in subfolder "db" (except that the db\data dir exists in both), each will result in a different installer
For this you can use the multiple builds feature. Here are the steps:
- go to the Media page and create a new MSI build
- in the Organization page create two features, one for each "db" folder
- in the Files and Folders page use the "Feature" combo to select the feature of the first "db" folder
- add the first "db" folder in "Application Folder"
- use the "Feature" combo to select the feature of the second "db" folder
- in the "Application Folder" -> "db" folder create a new folder and name it "Second db"
- double-click this folder and check the Install folder content into the parent folder option (this will install the contents of the "Second db" folder into the "db" folder)
- in the "Organization" page make sure that the feature of the first "db" folder is included only in the first build and the feature of the second "db" folder is included only in the second build

This way you will obtain two "db" configurations of the same package.
The folder APPDIR\bin\db\data\ must never be touched on updates.
This can be done by setting the Never Overwrite attribute for all components of the files in the "APPDIR\bin\db\data\" folder.
Files must always be overwritten (except for 2)) file modification dates or version information must be irrelevant.
In order to overwrite all files regardless of their version, you can try one of these approaches:
- use the "Ensure that this file overwrites any installed target file" option
- make sure that the installation folder is uniques for each version of the package (for example it contain the Product Version: "C:\My App 1.0.0")
Low/zero maintenance of the installation project when adding, renaming or removing files/folders from the installer ("Files and Folders")
This could be done by using folder synchronization. However, when the synchronization is refreshed, the "Ensure that this file overwrites any installed target file" option may be reseted. A solution would be to use a normal versioning system: each new version of the package contains files with the same versions or with higher versions.
If errors occurr a rollback must be performed.
Please note that a rollback can be performed only if the error occurs between the "InstallInitialize" and "InstallFinalize" standard actions.
In case of new installations the files already placed on disk must be removed (not the case with an ErrorMessage custom action) and the user be informed.
I'm afraid that this is not supported by Windows Installer. It could be done through a custom action, but I'm not sure how this custom action would look like. Please note that the custom action should detect the files already present on the target machine and remove them.
To get around the problem of "data.keep" being locked when trying to rename I considered adding the files in that folder into the MoveFile table at runtime in a custom action script, but here lack of documentation seems the problem.
Please note that the MSI database cannot be modified at runtime. Therefore, a custom action cannot modify the "MoveFile" table inside the MSI.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Plain project - except for leaving a folder untouched

Hello Cosmin,
cosmin wrote:
The folder APPDIR\bin\db\data\ must never be touched on updates.
This can be done by setting the Never Overwrite attribute for all components of the files in the "APPDIR\bin\db\data\" folder.
But because the contents of the data folder might change this would have to be automated if zero maintenance is to be achieved, wouldn't it?

(I could look up every file of that folder (and its subfolders) in the AIP file to assemble the list of components and then configure each component to "Never Overwrite" in the AIP file, perhaps with a script, couldn't I? That would introduce a dependency on the format of the data in the AIP file though, and more work.)



With best regards

Clemens Anhuth
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Plain project - except for leaving a folder untouched

Hi Clemens,
But because the contents of the data folder might change this would have to be automated if zero maintenance is to be achieved, wouldn't it?
I'm not sure if you can obtain zero maintenance for making sure that files in your package will not be overwritten. Please note that you can try this approach:
- create a feature for the "data" folder
- in the "Files and Folders" page select this feature through the "Feature" combo box and add the files in the "data" folder
- go to the "Organization" page and select the feature of the "data" folder
- press SHIFT+F4 on your keyboard
- in the "Search Result" pane select all components
- right-click them and select the "Properties" menu
- in the "Edit Components Properties" dialog check the "Never Overwrite" attribute

This way you will be able to set this attribute for all the files in the folder. When a file needs to be added to the folder you can follow these steps:
- make sure that the current feature is the "data" folder feature (the "Feature" combo on the toolbar)
- add the file in the "data" folder
- go to the "Organization" page and show the "Edit Components Properties" dialog
- the "Never Overwrite" attribute has a square in its checkbox, uncheck it (a square means that not all selected components use this attribute)
- check the option again

This approach uses a small number or steps during maintenance and allows you to manage multiple files and components more easily. Please note that this cannot be done through a script (it is not supported by Advanced Installer).

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Plain project - except for leaving a folder untouched

Hello Cosmin,

thank you for your reply and the instructions.



With best regards

Clemens Anhuth
canhuth
Posts: 241
Joined: Thu Jun 19, 2008 9:03 am

Re: Plain project - except for leaving a folder untouched

cosmin wrote:
To get around the problem of "data.keep" being locked when trying to rename I considered adding the files in that folder into the MoveFile table at runtime in a custom action script, but here lack of documentation seems the problem.
Please note that the MSI database cannot be modified at runtime. Therefore, a custom action cannot modify the "MoveFile" table inside the MSI.
Hello Cosmin,

I found this (possibly related) information:

How can I use a custom action to dynamically populate rows in the table?



Fortunately currently the need for this has vanished as we'll go with copying the "data.keep" folder to "data" in a custom action. This is unlikely to bump into exclusively locked files, end if something goes wrong we'll rollback (with the information you provided in another forum request) and inform the user about things. That'll do for us and be the least costly approach for us while allowing us to have zero maintenance for adding/remove/renaming files/folders inside the "data.keep" (by using synchronized folders).



Thank you for all your tips.



With best regards

Clemens Anhuth

Return to “Common Problems”