Okay, I have decided the only way I can do what I want to do with WiX (thanks to an old installer I didn't write that I now have to upgrade) is with some CUSTOM ACTIONS.
Basically, I need to back up a file before the RemoveExistingProducts and restore that file again after RemoveExistingProducts. I think this is what's called a "type 2 custom action."
The sequencing I think I understand, however, what I don't understand is first of all how I pass data to my C# action (the directory the file is in from the WiX) and how to reference my C# (DTF?) action with the Binary and CustomAction tags.
Also, does all this need to be in a tag? All the examples show it that way.
Here is what I have so far in the .WXS file...
<Binary Id="backupSettingsAction.dll"
SourceFile="backupSettingsAction.CA.dll"/>
<CustomAction
Id="BackupSettingsAction"
BinaryKey="backupSettingsAction.dll"
DllEntry="CustomAction"
Execute="immediate" />
<InstallExecuteSequence>
<Custom Action="backupSettingsAction.dll" Before="InstallInitialize"/>
<RemoveExistingProducts After="InstallFinalize" />
<Custom Action="restoreSettingsAction.dll" After="RemoveExistingFiles"/>
</InstallExecuteSequence>
The file I need to back up is a settings file from the previous install (which needs to remain intact), it is located in the directory:
<Directory Id="CommonAppDataFolder" Name="CommonAppData">
<Directory Id="CommonAppDataPathways" Name="Pathways" />
</Directory>
And even has a Component tag for it, though I need to back the file up that exists already:
<Component Id="Settings" Guid="A3513208-4F12-4496-B609-197812B4A953" NeverOverwrite="yes" >
<File Id="settingsXml" ShortName="SETTINGS.XML" Name="Settings.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Settings\settings.xml" Vital="yes" />
</Component>
And this is referencing the C# file that Visual Studio (2005) created for me:
namespace backupSettingsAction
{
public class CustomActions
{
[CustomAction]
public static ActionResult CustomAction1(Session session)
{
session.Log("backing up settings file");
//do I hardcode the directory and name of the file in here, or can I pass them in?
return ActionResult.Success;
}
}
}
Any help is greatly apprecaited. Thank you!