I have a WiX installer for an app that can generate two folders while running. I'd like these two folders to not be removed on uninstall however. I'm using RemoveFolderEx to remove the entire install directory, but wasn't sure if there was a way to exclude folders from being removed.
I've tried using a Custom Action with a PowerShell script to move the folders out of the directory, but this solution would rely on the script being somewhere outside of the install directory in order to be run before the folders are removed, and doing this unfortunately gets rid of the installer's portability.
Have you tried setting the msidbComponentAttributesPermanent attribute on the required Component(s) to make them permanent?
https://learn.microsoft.com/en-us/windows/win32/msi/component-table
Related
I have a Wix bundle which allows users to customize installation directory and passes the value to the package during installation. This is implemented using the approach described in this answer: How do I pass a default 'install location' to the RtfLicense bootstrapper?
If the user does not change install directory after running bundle and uninstalling it all files are deleted as expected. If the user does select another installation directory and runs bundle and uninstalls the app the files are not deleted. I guess this happens because the bundle passes default directory but it obviously isn't there. What's more the shortcut that's created during installation is deleted as the shortcut location does not depend on the installation directory.
How can I solve this issue?
The "install location" is not saved by the bundle. The packages have to save anything they need upon installation and read it back during other operations. For an MsiPackage, this is typically done using the "Remember Property" pattern. Directory paths are manipulated as properties so save any directory paths you need.
i have created an MSi installer. when i install this installer it also installs a visual studio project which is actually a tutorial project. When user runs this project it generates Bin and Obj folders. when i uninstall the install it does not delete all the those Bin and Obj folder which are generated after the installation.
Can you provide me some example how to use RemoveFolder tag in Wix to remove those two folders and the files inside them recursively.
Thanks
RemoveFile will only remove files that are installed by this msi.
To remove entire folder you have to use util:RemoveFolderEx. To use it you have to:
- Store [TARGETDIR] in registry on install;
- Retrieve it on any actions except on install and store in local variable (using RegsitrySearch)
- Add util:RemoveFolderEx action to your main component and pass your stored path variable to the Property attribute.
If you need an example I could write it for you.
I have a problem which is related to the execution of CopyFile on change/repair when using WIX to make a msi setup.
I have a feature which has a component which copies/moves a file from the source folder to a folder already present somwhere inside a users system. It is not the folder of my application. I am only moving this file and not installing it to the the target. This feature works fine if I install it using a complete setup. But when on initial install I chose not to install this feature and then try to install it during a " change " all other custom actions/components inside the feature are executed/installed except for the CopyFile component. This is critical to my setup and if it does not get copied my setup will fail.
Just wondering if anyone found a solution to a similar problem or ever came across a similar issue?
The component which contains the CopyFile operation is configured incorrectly. It should have an actual file or registry entry as a key path.
Although Windows Installer uses components to manage resources, the component key path is main factor which decides if the component is installed or not.
So a component without a resource as a key path will never be installed and the CopyFile operation it contains will never be executed.
When uninstalling my app, I'd like to configure the WiX setup to remove directories and like user settings and user data I want add a dialog with two check boxes and optionally remove all the files that were added. It looks like the uninstaller removes only the directories and files that were originally installed from the MSI file .
In other words, I want to give user a chance to Delete his data with a dialog while uninstall is called ?
Is this possible through WiX without resorting to custom actions? Any help would be appreciated.
To do this without using custom actions, see the WiX documentation regarding the RemoveFile and RemoveFolder elements. You can use these to remove files and folders on uninstallation. RemoveFolder will only work if the folder is empty.
Note that if the files are located in the user's application data directory, you will only be able to do this for the user that is uninstalling the application. You cannot easily do it for all users.
So I have files that are saved per user under the "PersonalFolder" Wix folder.
It seems that to have these per user files, I have to use a RegistryKey as the KeyPath.
Several of these files are per user configuration files that we do not want to overwrite during install, so I'm using the Permenent flag. Well now my users want to do a "clean install" so they delete the configuration files, but the registry keys persist. So now when they reinstall the files are missing.
Is there anything I can do in the installer for this?
As far as I understand, you are worried about the user deleting some of the files but not the registry keys before trying to install again. To account for this, your installer at the very beginning should check if anything is left over from the previous installation.
Check if the registry keys or directories exist
If they do, run a batch file to delete them before starting the actual installation.
Do the clean installation.
You can use CustomAction to run a batch file if some things are left over from the previous installation. Schedule the CustomAction in InstallExecuteSequence before the InstallFinalize.