卸载WiX时删除文件

问题描述:

在卸载我的应用程序时,我想配置 Wix 设置以删除所有原始安装后添加的文件。似乎卸载程序仅从MSI文件中删除了最初安装的目录和文件,而将以后添加的所有其他内容保留在应用程序文件夹中。换句话说,我要在卸载时清除目录。我该怎么做?

When uninstalling my application, I'd like to configure the Wix setup to remove all the files that were added after the original installation. It seems like the uninstaller removes only the directories and files that were originally installed from the MSI file and it leaves everything else that was added later in the application folder. In another words, I'd like to purge the directory when uninstalling. How do I do that?

使用 RemoveFile元素加上On = 卸载。例如:

Use RemoveFile element with On="uninstall". Here's an example:

<Directory Id="CommonAppDataFolder" Name="CommonAppDataFolder">
  <Directory Id="MyAppFolder" Name="My">
    <Component Id="MyAppFolder" Guid="*">
      <CreateFolder />
      <RemoveFile Id="PurgeAppFolder" Name="*.*" On="uninstall" />
    </Component>
  </Directory>
</Directory>

更新

它没有100%正常工作。它删除了文件,但是没有删除其他目录-安装后创建的
目录。有什么想法吗? – pribeiro

It didn't work 100%. It removed the files, however none of the additional directories - the ones created after the installation - were removed. Any thoughts on that? – pribeiro

很遗憾,Windows Installer不支持删除带有子目录的目录。在这种情况下,您必须诉诸自定义操作。或者,如果您知道什么是子文件夹,则创建一堆RemoveFolder和RemoveFile元素。

Unfortunately Windows Installer doesn't support deleting directories with subdirectories. In this case you have to resort to custom action. Or, if you know what subfolders are, create a bunch of RemoveFolder and RemoveFile elements.