Hi Michal and welcome to Advanced Installer forums.
Please keep in mind that this is the normal behavior. When a component is marked as "Permanent", it will not be removed by Windows Installer during the uninstallation, but the "Uninstall Cleanup" feature is basically a custom action meant to remove any file found in a folder.
In order to achieve what you want, you can go to the "Properties" dialog of that file and check the "Do not overwrite existing file" option from the "Operations" tab.
I'm Michal's collegue and we are facing another scenario:
Sometimes we have a situation when we want to preserve several files while performing an uninstall - this can be achieved by marking them as permanent and checking "Do not overwrite" checkbox within the file properties. This is quite fast and easy when you only have several files you want to keep and also works fine. But now we also need the package to be able to overwrite the same file during another installation but it's marked as "Do not overwrite" so it never gets overwritten. We tried to set a condition "REMOVE=ALL" so that this property only applies during an uninstall but it didn't work - the file does not get overwritten by a new installation of the same package. Then, imagine a scenario when you have multiple files you want to preserve:
We have an application that contains installation folder [APPDIR] with 1000 files. The end-user has rights to create custom files/folders within [APPDIR]. Let's say we want to perform an uninstall cleanup for the whole APPDIR so that all files and folders within are deleted BUT we also want to preserve 500 of the package installed files after the uninstall is done. Next step we want to achieve, when installing the same package again in the same APPDIR, we want it to OVERWRITE all the existing files. Because when we set property of it's parent folder, in this case APPDIR, to "always overwrite" it automatically overrides all the files properties under it and then the files are removed because of their new property setting. Basically we want the same file to be preserved during uninstall AND for the package to be able to overwrite the same file during installation. I hope this doesn't sound too confusing.
What you need could have been achieved simply by setting the "Permanent" flag for your files and the "Always overwrite" option, but only if you did not have the "Uninstall Cleanup" feature enabled.
In this case you can try the following configuration:
- select all the files that you do not want to be removed at uninstall (all at the same time) and check the "Do not overwrite existing file" option for them
- set the following condition: (REMOVE >< "FeatureID" OR REMOVE = "ALL") (where "FeatureID" is the ID of the feature that contains those files)
- create a new folder under the folder that contains those files and set the "Install folder content into the parent folder" option from its "Properties" tab
- copy all the files that you want to be replaced during a new installation from the parent folder and paste them into this sub-folder
- select all those files and check the "Always overwrite" option for them
- build and run the project
In the described scenario even if the files will be duplicated in the project, the size of the package will not increase, but the installation time will increase a little.
your solution works fine for us. We use Uninstall Cleanup feature to get rid of custom user data within the installation folders and we didn't quite know you could duplicate file properties in this way. So thanks for letting us know.
Is there any way you could improve "Uninstall cleanup" feature so that you could maybe define an exclusion list for files/subfolders? Then we wouldn't have to duplicate files the way we did. Or maybe set a checkbox to exclude those files that are flagged as permanent? Is that technically possible? That would be a great addition
FOLLOW US
Get the latest news in Application Packaging