Wix - 卸载删除文件但不删除文件夹

时间:2014-10-14 06:25:40

标签: wix windows-installer wix3.7

我使用heat cmd创建了一个wix安装程序。 卸载时,将删除所有文件,但不会删除所有文件夹。 这是我的代码的相关部分:

    <Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="$(var.PlatformProgramFilesFolder)">
    <Directory Id="companyDir" Name="companyName">
      <Directory Id="INSTALLFOLDER" Name="AppName">
        <Directory Id="INSTALLDIR" >
          <Directory Id="bin" Name="bin">
          <!-- Auto-start via Registry -->
          <Component Id="AppNameAutoStartUp" Guid="MYGUID">
            <Condition>AUTOMATIC_START_UP=1 OR Installed</Condition>
              <RegistryValue Id="App.rst" Root="HKCU" Action="write" Key="Software\Microsoft\Windows\CurrentVersion\Run" Name="AppName" Value="[#AppName.exe] -sc" Type="string" />
          </Component>

          </Directory>
        <Directory Id="docs" Name="Docs">
        </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Directory>
  <Directory Id="CommonAppDataFolder">
    <Directory Id="ConfCompanyDir" Name="Company">
      <Directory Id="CONFINSTALLFOLDER" Name="AppName">
        <Directory Id="CONFINSTALLDIR" >
          <Directory Id="conf" Name="conf">
          </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Directory>
  <!-- Shortcuts and Directories for Shortcuts -->
  <Directory Id="ProgramMenuFolder" Name="Programs">
    <Directory Id="ProgramMenuDir" Name="AppName">
      <Component Id="ProgramFilesShortcut" Guid="MYGUID">
        <Condition>DESKTOP_SHORTCUT = 1</Condition>
        <Shortcut Id="desktopAppName" Directory="DesktopFolder" Name="AppName" Target="[#AppName.exe]" WorkingDirectory="bin" Icon="AppIcon.ico">
        </Shortcut>
        <RemoveFolder Id="ProgramFilesShortcut" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
      <Component Id="ProgramMenuDir" Guid="MYGUID">
          <Shortcut Id="startmenuAppName" Directory="ProgramMenuFolder" Name="AppName" Target="[#AppName.exe]" Icon="AppIcon.ico" WorkingDirectory="bin" Arguments="-s">
          <!-- Set the AppID in order to get toasts to work -->
          <ShortcutProperty Key="System.AppUserModel.ID" Value="Company.AppName" />
        </Shortcut>
        <RemoveFolder Id="ProgramMenuDir" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </Directory>
  </Directory>
  <Directory Id="DesktopFolder" Name="Desktop" />
</Directory>

在卸载时删除Docs文件夹,但不删除bin文件夹(尽管它是空的,所有文件都被删除)。 有没有人知道为什么不删除它?

1 个答案:

答案 0 :(得分:0)

我在您的功能元素中添加了这样的代码:

<Component Directory='INSTALLDIR'>
  <RemoveFolder Id='CleanupApplicationFolder' On='uninstall' />
</Component>

所以你应该 INSTALLDIR 更改为主文件夹(它应该全部卸载)。