All you have to do is change <Custom Action="RestoreConfigFile" After="InstallInitialize" /> to <Custom Action="RestoreConfigFile" After="RemoveExistingProducts " />
It is just a matter of time that you have. You report all three actions after InstallInitialize, so it is very possible that they do not remain in the order in which they are written. It is always the best idea to explicitly indicate in which order you want them. Best, full fix:
<Custom Action="BackupConfigFile" After="InstallInitialize" /> <RemoveExistingProducts After="BackupConfigFile" /> <Custom Action="RestoreConfigFile" After="RemoveExistingProducts " />
EDIT: (Based on comments) To create a custom action in MSI, you need to create a CustomAction element. You also need code to create a custom action. However, if you are only trying to copy a file, I would suggest using the CopyFile element. This is much simpler and cleaner than going through all the steps of a user action to do what I think you are going to do.
source share