Search code examples
wixwindows-installerwix3wixsharp

Wixsharp MSI. How to uninstall files that are not shared between components and leave those that are shared in dir?


I have 10 services and they share a few of the same .dll-s. When I install those services, dll-s are installed in the same folder and the ones that are shared are not duplicated (which is what i want), but when i uninstall of of the services. lets say service number 5, The msi also uninstalls all the dll-s for that service, including the shared ones. How can I uninstall just the ones that are not shared for each service?


Solution

  • One Line Answer: You must make sure that the shared files are not assigned to single features only - as this will remove them on uninstall if no other features register them as "clients" or "users" of the files.


    Long Version: You must have several features since you allow services to be installed and uninstalled individually. Have you perhaps assigned some of the shared components / files to only one feature? If so, then the above problem could show up. There are a few options:

    1. Shared Feature: Perhaps create a hidden, common feature and move all shared components / files there? You can then hide it from the GUI so they won't be uninstalled until complete uninstall of the whole product. The end user can never select them for uninstall (msiexec.exe commands can still uninstall them unless you prohibit that too).

    2. Update all Features: You should also be able to add all the shared components to each and every feature so each feature lists all shared files in addition to the individual service files. I would prefer a shared, hidden feature like described above. However if you want some shared files to go away when you uninstall individual services, then you can add the components / files to only those (service) features. As that feature gets uninstalled no other features report "I need those files" and the files get uninstalled.

    3. Burn: Just mentioning that you could deliver a separate MSI per service and a shared MSI with shared files using a Burn bootstrapper / bundle. Based on your comment above this is not what you want to do. This does allow you, though, to update individual services without recompiling the big setup with all services in there: Use a single setup or several smaller ones? (and also to update the common files, without recompiling all service setups).

    As an example for point 2 above: if you uninstall services 1, 2 and 3 and they are the only ones that point to some of the shared files, those shared files will be uninstalled as the last service using it gets uninstalled.