Reputation: 31
I have a Windows Installer Project that installs files to C:\Program Files\MyInstalledFiles
. When I run the MSI, I want it to check if there is already a folder called MyInstalledFiles
in the install destination and, if so, rename it to MyInstalledFiles-OLD
. This way I can back up any files that already exist.
The catch is that I want this to be done BEFORE the files are installed by the MSI. Otherwise, it will overwrite the existing files and I will lose them. Is there any way for me to rename the folder before the installation using custom actions?
Upvotes: 1
Views: 2127
Reputation: 20790
Your question has a Visual Studio tag, and that might mean you are using a Visual Studio setup project to create your MSI setup. If you are using a VS setup project then the answer is no, you cannot run a custom action before the files are installed. All custom actions generated by Visual Studio installer projects run after the files are installed, despite names such as "BeforeInstall".
Other tools allow custom actions to be run before files are installed, and basically you'd have a deferred custom action sequenced before the InstallFiles action.
Whether existing files will be overwritten is by no means certain. If you had a Windows Installer based setup that installed a database that was then updated by the application an upgrade like Visual Studio's RemovePreviousVersions will not overwrite the existing files.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa370531(v=vs.85).aspx
Upvotes: 2
Reputation: 54
I had similar issue for a project before, and achived by calling an executable on Install.
After that, you'll see your custom action under Custom Actions>Install tree.
Edit: And, unfortunately, there is no way to make any control in early stages. If this doesn't help, you need to find another Installer extension.
Upvotes: 1