Q:

WIX/MSI - Is it possible to make a package which leaves files that existed prior to installation when you uninstall

I am using WIX to create MSI's which install standard files (no exe, com's, DLL's etc). On some users computers some of the files in the MSI may already exist. During the install this is not a problem as MSI automatically updates files that are older etc. However, during uninstall I hit my problem.
It is easiest to explain with an example:
Joe Bloggs has "file B" on their computer. This file has not been installed by an MSI package and is not being track by the Microsoft Installer system in anyway. It is just a normal file on the computer.
Joe Bloggs downloads and installs my package which contains "file A", "file B" and "file C". When he installs my package the Microsoft Installer system checks "file B" and establishes it is identical to the "file B" in my package. It therefore does not replace "file B" but it does mark the MSI component that file B is part of as installed.
Joe Bloggs then decides he does not like my software so uninstalls my package. When he does this all 3 files are removed despite "file B" existing before my package was installed. My investigations have established that this is because the component that contains "file B" is marked as installed. Therefore when you uninstall the package it removes "file B".
This is all a bit technical but hopefully there is a WIX / MSi expert out there that knows a solution.
Thanks
Jim

A:

If the files may already exist on the machine mark Component/@SharedDllRefCount="yes"
Windows installer will then automatically update the reference count if it finds the files already existing. 

A:

This is usually done through backup and restore custom actions. 
Basically, you write a custom action which can copy some files based on the parameters it receives. You can then use this custom action twice in your installer:

once during install to copy the original file in a backup folder (usually temp or application data)
once during uninstall to copy the backup file back in the original location

