Wix major upgrade

2019-03-13 02:57发布

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

3条回答
The star\"
2楼-- · 2019-03-13 03:26

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">
查看更多
在下西门庆
3楼-- · 2019-03-13 03:36

You can use the UPGRADINGPRODUCTCODE property to check if you are upgrading. We use this to determine if we should run our 'clean up' custom action:

<Custom Action="" After="CleanUpFiles">
  <![CDATA[REMOVE="ALL" AND NOT UPGRADINGPRODUCTCODE]]>
</Custom>

I do agree with Rob, in that the config is user data, stored in their AppData folders, and never created by the MSI. Instead it is set do a default value (which we store as a default config in the programs files), and copied over by the app itself. But we don't want to leave these things cluttering a user's machine if they want to uninstall our product, so we made a CleanUpFiles that searches the HD for any garbage left behind.

查看更多
ゆ 、 Hurt°
4楼-- · 2019-03-13 03:43

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.

查看更多
登录 后发表回答