Reputation: 9675
We develop C# application and package it by Wix to MSI file that can be installed. The application executable and .dll files are installed to the standard location in ProgramFilesFolder.
When started application creates local .sdf file (database), if it doesn't exist.
When we uninstall (for example as part of the upgrade to a newer version) everything gets deleted, except this .sdf file. When we install newer version it picks up the old .sdf file and continue using it.
Now the problem is that .sdf file currently lives under ProgramFilesFolder as well. We don't want to "store travel luggage in the engine compartment", so we are moving this .sdf file into the ProgramData.
So we are going to do this change in application code - to use .sdf file in different path. When we upgrade next time, we need to move existing .sdf file from ProgramFilesFolder to ProgramData.
Question - what's the ideal method of moving this file?
1) In the Wix setup code - to recognize if upgrade is happenning from the "old" version (older then the version in which we changed the location of .sdf file) to the "new" (newer or equal to the version of the change) and in this case move file. Good thing here is that Wix "knows" all the version numbers and can do the move conditionally based on them.
2) In the C# application code - it is probably simpler compared to writing CustomAction in Wix. But application code doesn't know anything about versions, so we can't use the same logic of using "old" and "new" version as in case of Wix. So we can only use generic logic, for example use file from the new location if it exists there, otherwise check if file exists in the old location and then move it to a new location, if file is present in both - ignore the file from the old location and just use the file in the new location.
Could you please help in choosing the best way?
Any drawbacks\risks with the described approaches?
Any better solution?
Upvotes: 2
Views: 1094
Reputation: 7963
I would control everything by WIX, since you can set properties and conditionals to obtain the desired behavior in your install process.
I recommend that you start here Checking for oldies
The change that you will need to do in the CA is to move or not the file depending on the version that was found.
If a bigger change is required look at this Replacing Ourselves
HTH
Upvotes: 1