title: Custom action in WIX during uninstall
body: <p>I am using WIX for creating the installer of my application. 
  During uninstalling the application, I want to call a function in a DLL file before the uninstaller deletes the files which the DLL file is part of them. I checked other related post like <a href="https://stackoverflow.com/questions/17587357/custom-action-before-msi-uninstallation-with-wix">this post</a> to proceed.</p>
  
  <p>I created a <code>CustomAction</code> as follows: </p>
  
  <pre><code>&lt;CustomAction Id="UnRegister" 
                FileKey="mydll.dll" 
                DllEntry="cleanup" 
                Execute="immediate" 
                Return="ignore"/&gt;
  </code></pre>
  
  <p>and then the <code>InstallExecuteSequence</code> tag:</p>
  
  <pre><code>&lt;InstallExecuteSequence&gt;
      &lt;Custom Action="UnRegister" After="InstallInitialize"&gt;Installed AND NOT UPGRADINGPRODUCTCODE&lt;/Custom&gt;
  &lt;/InstallExecuteSequence&gt;
  </code></pre>
  
  <p>The problem is when I try to uninstall the application, the files are removed first and then the installer calls the cleanup() function in DLL. After the error the uninstall rolls back and fails.</p>
  
  <p>How can I configure the WIX installer so that it calls the function first and then delete the files during uninstall?</p>
  
  <p>Thanks</p>