A: 

First thing you'll probably need to do is get rid of that RemoveFolder in your CommonAppDataPathwaysFolderComponent component. Thats going to delete your directory and everything it contains (including settings.xml). Add the neveroverwrite back in and see what happens.

What version of wix are you using? 3 right?

Mark Synowiec
Yes, version 3.
Joshua
A: 

Windows installer only installs a component if the keypath is not yet present, or points to a file with a lower version. In the typical case of a single-file component, wix defaults to using that file as the keypath. In this case the keypath of the CommonAppDataPathwaysFolderComponent component is a registry key; it has been explicitly marked with the keypath=yes attribute.

You schedule the uninstall of the old version after the installation of the new version. So if the keypath for this component is the same for the old and the new version, then things should work as you want.

The fact that it does not work, implies that you have changed the keypath of the component. Apparently the old installer did not write a "Software\TDR\Pathways, Installed=1" value to the registry. The new installer looks for this registry key, doesn't find it, and decides to install the CommonAppDataPathwaysFolderComponent - overwriting the old SETTINGS.XML file in the process.

Wim Coenen
A: 

when running your code in a test I got this warning

warning LGHT1076 : ICE57: Component 'CommonAppDataPathwaysFolderComponent' has both pe r-user and per-machine data with an HKCU Registry KeyPath.

and The error in the log file whilst running your code is this

C:\Documents and Settings\All Users\Application Data\Pathways\Settings.xml; Overwrite; Won't patch; Existing file is unversioned and unmodified - hash doesn't match source file

Which indicates the xml file component has per machine data (the xml file) with a per user registry key path.

Use the xml file as a keypath for the component like so:

<Component Id="CommonAppDataPathwaysFolderComponent" Guid="087C6F14-E87E-4B57-A7FA-C03FC8488E0D">
    <CreateFolder>
        <Permission User="Everyone" GenericAll="yes" />
    </CreateFolder>

    <RemoveFolder Id="CommonAppDataPathways" On="uninstall" />
    <File Id="settingsXml" KeyPath="yes" ShortName="SETTINGS.XML" Name="Settings.xml" DiskId="1" Source="\\fileserver\Release\Pathways\Dependencies\Settings\settings.xml" Vital="yes" />
</Component>

This will make Windows Installer use unversioned file comparison when deciding whether or not to replace this file.

you have correctly scheduled RemoveExistingProducts action after the InstallFiles action which makes sure that the new versions are installed before removing the old versions.

Charles Gargent
Trying this did get rid of the light error, but still the problem remains, the settings file is replaced. And also, the MDF and LDF files that I need to be replaced are remaining.
Joshua
I wonder if that is because the old installed version component is different from the newer one, it has a different keypath and thus needs reinstalling. If that is the case then there isnt much you can do other than a custom action that copies the file to a temp location and then back once everything has been installed.
Charles Gargent
Please see my post as an answer in this question. It's close! Putting the settings into it's own component helped, and now the problem is that the database is being preserved too, and that needs to be replaced! THANK YOU!
Joshua
A: 
Joshua