How do I use WIX to prevent overwriting a config file during a 'Major Upgrade'?
I want the file to be installed on the initial install, removed on uninstall, and left unchanged on a 'Major Upgrade'.
Thanks
The most straight forward way would be to schedule your RemoveExistingProducts after InstallExecute or InstallFinalize. That way the config file is not removed and then installed again (like if you schedule before InstallInitialize). Of course, scheduling RemoveExistingProduct so late means you need to be very careful about your Component Rules.
My personal favorite is to treat configuration like "user data" and not have the installtouch it at all. You ship defaults with the application but any changes are made by the user in their private user profile. Gets you out of all kinds of nasty migration problems that just aren't solved well during setup.
Do you ever want it overwritten? If not in cases like this I assign the config files to their own components and mark them as Never Overwrite. This way upgrades will not overwrite the file but uninstalls will remove it.
e.g.
<Component Id="myComp" Guid="myguid" NeverOverwrite="yes">
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With