Wix major upgrade

前端 未结 3 1036
天涯浪人
天涯浪人 2021-02-04 10:47

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

相关标签:
3条回答
  • 2021-02-04 11:27

    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.

    0 讨论(0)
  • 2021-02-04 11:30

    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.

    0 讨论(0)
  • 2021-02-04 11:33

    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">
    
    0 讨论(0)
提交回复
热议问题