wix - 如何删除非空文件夹 [英] wix - how to delete non-empty folder

查看:22
本文介绍了wix - 如何删除非空文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经阅读了这个网站上的所有主题,但没有找到我需要的.

I have read all topics on this site with problem like this, but not find what i need.

我有一个程序的两个版本:旧版本和新版本.在旧版本中,我有文件夹 f1.在新版本中我没有这个文件夹 f1.

I have two versions of one program: old and new. In old version i have folder f1. In new version i have no this folder f1.

当新程序的安装程序检测到旧版本时,它会删除这个旧版本,但不会删除文件夹 f1.

When installer of new programm detected old version, it delete this old version, but not folder f1.

如何从新版本的安装程序中删除 f1?

How can i delete f1 from installer of new version?

      <Component Id ="deleteall"  Guid="AA11A32B-9E1E-458A-8C94-3EFEDA77E494" >
        <RemoveFolder Id='iDocDir' On='both' />
      </Component>

      <Directory Id="iDocDir" Name="iDocs">
      </Directory>

不工作=(

推荐答案

你应该看看 RemoveFolderExUtilExtension中的元素.它完全符合您的要求.Bob Arnson 之前曾在博客上发表过相关文章.

<Component Id="deeletall" Guid="PUT-GUID-HERE">
    <util:RemoveFolderEx Id="RemoveiDocDir" On="uninstall" Property="iDocDir" />
</Component>

它通过将临时行写入 RemoveFile 表来工作.但是,如手册中所述,使用它有一些限制:

It works by writing temporary rowes to the RemoveFile table. There are restrictions to using this, however, as noted in the manual:

因为它可能会极大地影响 Windows Installer 的文件成本核算,临时行必须在 CostInitialize 标准之前写入行动.不幸的是,MSI 不会为直到稍后,在 CostFinalize 中的包中的目录层次结构行动.

Because it might dramatically affect Windows Installer's File Costing, the temporary rows must be written before the CostInitialize standard action. Unfortunately, MSI doesn't create properties for the Directory hierarchy in your package until later, in the CostFinalize action.

在删除文件夹的典型用例中的简单解决方法卸载是将目录路径写入注册表并加载在卸载期间.

An easy workaround for a typical use case of removing a folder during uninstall is to write the directory path to the registry and to load it during uninstall.

如果您使用自定义操作来设置属性,请确保它们是在 WixRemoveFoldersEx 自定义操作之前安排.

If you use custom actions to set properties, ensure that they are scheduled before the WixRemoveFoldersEx custom action.

在 Bob 的帖子中:

And also in Bob's post:

由于添加要删除的目录和文件会影响 MSI 的文件成本计算,RemoveFolderEx 必须在计算成本之前做它的事情.不幸的是,MSI 没有为目标目录设置属性直到成本核算完成.

As adding directories and files to be deleted affects MSI’s file costing, RemoveFolderEx has to do its thing before costing. Unfortunately, MSI doesn’t set up properties for target directories until after costing is complete.

如果您已经保存了之前的安装路径(Rob 解释了如何执行此操作这里) 在注册表中,你很好,因为 AppSearch 操作在 CostInitialize 之前运行.

If you already save your previous installation path (Rob explains how to do this here) in the registry, you're fine, as the AppSearch action runs before CostInitialize.

这篇关于wix - 如何删除非空文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆