c# - Wix 设置 - 如何定义卸载

标签 c# wix

我已经为我的 C# 项目创建了我的第一个 Wix 安装程序(我是 Wix 的初学者)。

安装程序创建了一个 msi 文件,这个文件运行良好。安装后,所有 DLL 和 .exe 都在“C:\Program Files (x86)\MyApplication”中创建

但是当我右键单击 msi 并选择卸载时,会显示一个卸载菜单,没有错误,但文件夹“C:\Program Files (x86)\MyApplication”没有被删除。

如何定义卸载函数来删除这个文件夹?

有一部分是我的Product.wxs

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
     xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
  <Product Id="*"
           Name="My Application"
           Language="1033"
           Version="1.0.0.0"
           Manufacturer="Me"
           UpgradeCode="36944ae1-9e9f-4ef0-a860-9d894e0c28ef">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine"/>
    <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed."/>
    <Media Id="1" Cabinet="myApplication.cab" EmbedCab="yes"/>

    <Feature Id="ProductFeature" Title="My Application" Level="1">
      <ComponentGroupRef Id="ProductComponents"/>
      <ComponentRef Id ="ApplicationShortcut"/>
      <ComponentRef Id ="ApplicationShortcutDesk"/>
      <ComponentRef Id ="RemoveAll"/>
    </Feature>
  </Product>

  <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramMenuFolder">
        <Directory Id="ApplicationProgramsFolder" Name="My Application"/>
      </Directory>
      <Directory Id="DesktopFolder" SourceName="Desktop"/>
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="My Application">
          <Directory Id="fr" Name="fr"/>

          <Component Id="RemoveAll" Guid="{63F6943C-7707-41CA-BAB9-7438471EC81E}">
            <RemoveFile Id="RemoveAllFilesOnUninstall" Directory="INSTALLFOLDER" Name ="*.*" On ="uninstall"/>
            <RemoveFolder Id="RemoveAllFoldersOnUninstall" Directory="INSTALLFOLDER" On="uninstall"/>
            <RegistryValue Root="HKLM" Key="Software\Microsoft\MyApplication" Name="Path" Type="string" Value="[INSTALLFOLDER]" KeyPath="yes" />
            <util:RemoveFolderEx On="uninstall" Property="INSTALLFOLDER" />
          </Component>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>

  <Fragment>
    <DirectoryRef Id="ApplicationProgramsFolder">
      <Component Id="ApplicationShortcut" Guid="{3B0B5064-807C-4E29-A701-E77BE8B8FA86}">
        <Shortcut Id="ApplicationStartMenuShortcut"
                  Name="My Application"
                  Target="[#MyApplication.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>
    <DirectoryRef Id="DesktopFolder">
      <Component Id="ApplicationShortcutDesk" Guid="{61087C99-9CA8-4191-8251-219DFDAFC666}">
        <Shortcut Id="ApplicationStartDeskShortcut"
                  Name="My Application"
                  Target="[#MyApplication.exe]"
                  WorkingDirectory="INSTALLFOLDER"/>
        <RemoveFolder Id="DesktopFolder" On="uninstall"/>
        <RegistryValue Root="HKCU" Key="Software\Microsoft\MyApplication" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
      </Component>
    </DirectoryRef>
  </Fragment>

  <Fragment>
    <ComponentGroup Id="ProductComponents">
      <Component Id="ProductComponent" Guid="{5C62E31A-C787-4B45-A4F7-2324A12C72D1}" Directory="INSTALLFOLDER">
        <!-- List of DLL/EXE -->
    </ComponentGroup>
  </Fragment>
</Wix>

编辑:我现在正在使用 UtilExtension 并且 INSTALLFOLDER 现在已正确删除。唯一重命名的元素是 ApplicationShortcutDeskApplicationStartMenuShortcutRemoveFolder 如何用于快捷方式?

最佳答案

感谢Anton Sutamin,我终于找到了问题所在.

我的 GUID 阻止了删除(参见 that post)

使用新的 GUID,一切正常,没有 CustomAction/RemoveFile/etc...

关于c# - Wix 设置 - 如何定义卸载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39221254/

相关文章:

c# - 从另一个类调用主类的公共(public)方法

c# - 使用 Azure Functions 自动将 Excel 保存为 CSV

c# - 在 C++ 和 C# 中,多个条件检查是按预定顺序还是随机顺序执行的?

crystal-reports - 如何在 WiX 中检查 Crystal Reports for .NET Framework 4.0 安装

compression - 使用 WIX 对 MSI 安装进行最大压缩

xslt - 使用 XSLT 1.0 根据引用的 XML 文件中的元素删除元素(WXS 组件/文件/等)

添加/删除程序中的 Wix 图标

c# - 什么是Windows中的COM

Wix - 根据条件安装目录

c# - 使用多种形式