WIX util:RemoveFolderEx不起作用

时间:2017-09-22 10:48:30

标签: wix

我有一些wix安装程序和bootstraper用于某些应用程序在工作期间在应用程序文件夹中创建其他文件,我必须在卸载期间删除这些文件。根据{{​​3}}和其他相同的例子,我有下一部分代码:

  1. 定义属性:

    <Property Id="APPLICATIONFOLDER">
      <RegistrySearch Key="SOFTWARE\ProductName" 
                      Root="HKLM" 
                      Type="raw" 
                      Id="APPLICATIONFOLDER_REGSEARCH" 
                      Name="Path" />
    </Property>
    
  2. 定义组件:

    <Directory Id="APPLICATIONFOLDER" Name="ProductName">
      <Component Id="RemoveAll" Guid="some-guid">
        <RegistryValue Root="HKLM" 
                       Key="Software\ProductName" 
                       Type="string" 
                       Name="Path" 
                       Value="[APPLICATIONFOLDER]" 
                       KeyPath="yes"/>
        <util:RemoveFolderEx On="uninstall" 
                             Property="APPLICATIONFOLDER" />
      </Component>
    </Directory>
    
  3. 向功能添加组件:

    <Feature Id="ProductFeature" Title="ProductName" Level="1">
      ...
      <ComponentRef Id="RemoveAll" />
      ...
    </Feature>
    
  4. 然后,当我尝试卸载此应用程序时,我在wix日志中有下一行:

    ...
    MSI (s) (B4:64) [13:05:58:798]: PROPERTY CHANGE: Adding APPLICATIONFOLDER property. Its value is 'C:\Program Files(x86)\ProductName\'
    ...
    Action start 13:05:58: WixRemoveFoldersEx.
    MSI (s) (B4:48) [13:05:58:914]: PROPERTY CHANGE: Adding _APPLICATIONFOLDER_0 property. Its value is 'C:\Program Files (x86)\ProductName\'.
    WixRemoveFoldersEx:  Recursing path: C:\Program Files (x86)\ProductName\ for row: wrfE932DA8DA501DD981493D5D9F4EFDD75.
    MSI (s) (B4:64) [13:05:58:918]: Doing action: CostInitialize
    MSI (s) (B4:64) [13:05:58:918]: Note: 1: 2205 2:  3: ActionText 
    Action ended 13:05:58: WixRemoveFoldersEx. Return value 1.
    ...
    

    但是没有任何内容,所有其他文件都存在于应用程序文件夹中,因此该文件夹也存在。我不知道为什么,我不知道需要改变什么来解决这个问题。

    有人能帮助我吗?

1 个答案:

答案 0 :(得分:0)

在删除文件夹之前,您需要删除应用程序创建的所有文件。尝试这样的事情:

<Component Id="RemoveOrphanFiles" Guid=InsertGUID KeyPath="yes">
   <RemoveFile Id="RemoveFiles" Name="*.*" On="uninstall" />
</Component>

并添加条件,使其仅在卸载时运行... 希望这有帮助!

相关问题