title: WiX installer remove files on uninstall but not on upgrade
body: <p>I have a program that installs with a WiX installer.</p>
  
  <p>The program itself creates a number of files in the [CommonAppDataFolder]\[MyAppName]\ directory. These files all have the same extension (lets call it .dat).</p>
  
  <p>On <strong>upgrading</strong>, I want to <strong>retain</strong> these files.<br>
  On <strong>uninstalling</strong>, I want to <strong>remove</strong> these files.  </p>
  
  <p>I am currently deleting the files as so:</p>
  
  <pre><code>&lt;Directory Id='CommonAppDataFolder'&gt;
    &lt;Directory Id='MyCommonAppDataFolder' Name='MyAppName'&gt;
      &lt;Component Id='RemoveFilesComponent' Guid='71cb0cd8-8459-4a8f-89b7-f00977aa7b70'&gt;
        &lt;RemoveFile Id='RemoveFiles' Name='*.dat' On='uninstall'/&gt;
      &lt;/Component&gt;
    &lt;/Directory&gt;
  &lt;/Directory&gt;
  </code></pre>
  
  <p>And I have this to facilitate upgrades:</p>
  
  <pre><code>&lt;InstallExecuteSequence&gt;
    &lt;RemoveExistingProducts After='InstallInitialize'/&gt;
  &lt;/InstallExecuteSequence&gt;
  </code></pre>
  
  <p>Now, when I uninstall, the .dat files are removed correctly.<br>
  However, when I upgrade, the .dat files are also removed. I guess because an upgrade is performing an uninstall on the previous version.</p>
  
  <p>Am I approaching this problem correctly? How can I retain the files on upgrade, while removing them on uninstall?</p>