【问题标题】:WiX Uninstall does not uninstall anythingWiX Uninstall 不会卸载任何东西
【发布时间】:2017-01-18 12:56:01
【问题描述】:

我是使用 WiX 的新手,我创建了一个简单的 perUser 应用程序安装,其中包含一些文件、一些注册表项和一个文件关联。我将所有内容都放入带有 UID 的组件中。安装过程运行良好。

我读了很多关于如何定义什么以及如何卸载它们的文章,但是到处都写着卸载过程会找到每个组件(文件、注册表项等)并自动删除它们。相反 - 在“成功”卸载后,我可以找到每个文件,每个注册表项都没有受到影响。我希望删除所有内容(文件、注册表项、文件关联)。

我做错了什么?

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <!-- DO NOT MODIFY THESE SETTINGS -->
  <?define Manufacturer="MyCompany" ?>
  <?define UpgradeCode="C9998877-7796-4E81-B45B-E7068A15E229" ?>
  <?define VersionNumber="3.3.2"?>
  <?define ProductName="MyCompany Release dosomething" ?>
  <?define ApplicationName="MyCompany Release dosomething App" ?>
  <?define Description="MyCompany Release dosomething Tool" ?>

  <!-- MODIFY THESE SETTINGS AT EVERY NEW VERSION -->
  <?define dosomething_exe_src = "FILES\MyCompanyDoSomething.exe" ?>
  <?define dosomething_ini_src = "FILES\MyCompanyDoSomething.exe.config" ?>
  <?define dosomething_eula_src = "FILES\eula.rtf" ?>


  <Product Id="*"
            Name="$(var.ProductName)"
            Language="1033"
            Version="$(var.VersionNumber)"
            Manufacturer="$(var.Manufacturer)"
            UpgradeCode="$(var.UpgradeCode)">
    <Package Id="*"
             InstallerVersion="200"
             Compressed="yes"
             InstallScope="perUser"
             Manufacturer="$(var.Manufacturer)"
             Description="$(var.Description)"
            InstallPrivileges="limited" />
    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

    <Property Id="ALLUSERS" Secure="yes" />




    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion Minimum="$(var.VersionNumber)" IncludeMinimum="no"
                      OnlyDetect="yes"
                      Property="NEWERVERSIONS" />
      <UpgradeVersion Minimum="0.0.0" IncludeMinimum="yes"
                      Maximum="$(var.VersionNumber)" IncludeMaximum="no"
                      OnlyDetect="no"
                      IgnoreRemoveFailure="yes"
                      Property="OLDERVERSIONS" />
    </Upgrade>

    <Condition Message="A newer version of [ProductName] is already installed. Exiting installation.">
      <![CDATA[Installed OR NOT NEWERVERSIONS]]>
    </Condition>

    <Condition Message="!(loc.LaunchCondition_AllUsers)">
      NOT ALLUSERS
    </Condition>

    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Installation Variables                                                                      :: -->
    <Property Id="WixAppFolder" Value="WixPerUserFolder" />
    <Property Id="ApplicationFolderName" Value="Install path" />
    <Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER"/>
    <WixVariable Id="WixUILicenseRtf" Value="FILES\eula.rtf" />


    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Main Installation Directory Structure                                                       :: -->

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="LocalAppDataFolder">
        <!-- perUser case, it is redirected automatically to LocalAppDataFolder -->
        <Directory Id="ProgramFilesHK" Name="$(var.Manufacturer)">
          <Directory Id="APPLICATIONFOLDER" Name="$(var.ApplicationName)">
            <Component Id="CMP_dosomething_exe" Guid="0BA6F4AB-9ED4-4CF2-BDFF-0C95F1DF4BA0" Permanent="no">
              <CreateFolder />
              <RemoveFolder Id="RemoveFolder_ProgramFilesHK" Directory="ProgramFilesHK" On="uninstall" />
              <RemoveFolder Id="RemoveFolder_ApplicationFolder" Directory="APPLICATIONFOLDER" On="uninstall" />

              <File Source="$(var.dosomething_exe_src)" Id="dosomething_exe_file" Vital="yes" />

              <ProgId Id="$(var.ApplicationName).Document" Description="$(var.Description)" Advertise="no">
                <Extension Id="MyCompanyDoSomething" ContentType="application/MyCompanyDoSomething">
                  <Verb Id="Open" Command="Open" Argument="&quot;%1&quot;" TargetFile="dosomething_exe_file"/>
                  <MIME Advertise="no" ContentType="application/MyCompanyDoSomething" Default="yes" />
                </Extension>
              </ProgId>
              <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplication" ForceDeleteOnUninstall="yes">
                <RegistryValue Name="Version" Value="[ProductVersion]" Type="string" KeyPath="yes"/>
              </RegistryKey>
            </Component>
            <Component Id="CMP_dosomething_ini" Guid="6F0201F1-A1C1-4378-9ED7-5D47AB750AD1">
              <File Source="$(var.dosomething_ini_src)" Id="dosomething_ini_file" Vital="yes"/>
              <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplication" ForceDeleteOnUninstall="yes">
                <RegistryValue Name="Version" Value="[ProductVersion]" Type="string" KeyPath="yes"/>
              </RegistryKey>
            </Component>
            <Component Id="CMP_eula_doc" Guid="{9D320C1F-E16A-46D3-AF2F-5AE496B8C365}">
              <File Source="$(var.dosomething_eula_src)" Id="dosomething_eula_file" Vital="yes"/>
              <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplication" ForceDeleteOnUninstall="yes">
                <RegistryValue Name="Version" Value="[ProductVersion]" Type="string" KeyPath="yes"/>
              </RegistryKey>
            </Component>
          </Directory>
        </Directory>
      </Directory>

      <Directory Id="DesktopFolder">
      </Directory>

      <Directory Id="ProgramMenuFolder">
        <Directory Id="AppShortcutsDir" Name="$(var.ApplicationName)" />
      </Directory>
    </Directory>


    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Desktop -> Shortcut to start the application                                                :: -->
    <DirectoryRef Id="DesktopFolder">
      <Component Id="CMP_DesktopShortcut" Guid="{E6024E33-E5B8-4136-9402-22BA0614013D}">
        <Shortcut Id="DAppStarterShortcut" Name="$(var.ApplicationName)" Description="$(var.Description)" Target="[APPLICATIONFOLDER]MyCompanyDoSomething.exe" />
        <RegistryValue Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>

    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Start Menu -> Shortcuts to start the application, eula, uninstall, etc.                     :: -->
    <DirectoryRef Id="AppShortcutsDir">
      <Component Id="CMP_StartMenuShortcut" Guid="{439DAE58-5DE5-4A45-952E-05956D5B4A49}">
        <Shortcut Id="SAppStarterShortcut" Name="$(var.ApplicationName)" Description="$(var.Description)" Target="[APPLICATIONFOLDER]MyCompanyDoSomething.exe" />
        <Shortcut Id="SEulaReadShortcut" Name="$(var.ApplicationName) EULA" Description="End User Agreement" Target="[APPLICATIONFOLDER]eula.rtf" />
        <Shortcut Id="SUninstallShortcut" Name="Uninstall $(var.ApplicationName)" Description="Uninstall $(var.ApplicationName) and all of its components" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" />
        <RemoveFolder Id="RemoveMyShortcutsDir" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>




    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Installation Feature Tree                                                                    :: -->
    <Feature Id="MyCompanyDosomethingTool" Title="MyCompany Dsomething Tool" Level="1" ConfigurableDirectory="APPLICATIONFOLDER">
      <ComponentRef Id="CMP_dosomething_exe" />
      <ComponentRef Id="CMP_dosomething_ini" />
      <ComponentRef Id="CMP_eula_doc" />
      <ComponentRef Id="CMP_StartMenuShortcut" />
      <ComponentRef Id="CMP_DesktopShortcut" />
    </Feature>

    <InstallExecuteSequence>
      <RemoveExistingProducts After="InstallInitialize" />
      <InstallExecute After="RemoveExistingProducts" />
    </InstallExecuteSequence>

    <UIRef Id="WixUI_Mondo" />
  </Product>
</Wix>

【问题讨论】:

  • 请添加一些代码。
  • 对不起。编辑了原始问题 - 添加了源代码。

标签: wix installation components uninstallation


【解决方案1】:

在组件元素上,您可以添加: RemoveFile、RemoveFolder、RemoveRegistryKey 和 RemoveRegistryValue 元素。见http://wixtoolset.org/documentation/manual/v3/xsd/wix/component.html

示例(文件夹和密钥):

<Directory Id="ProgramMenuFolder" Name="Programs">
    <Directory Id="ProgramMenuDir" Name="AppName $(var.Version)">
      <Component Id="ProgramMenuDir" Guid="*">
        <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
        <RegistryValue id= Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
        <RemoveRegistryKey Id='RegCleanup' Root='HKCU' Action='removeOnInstall' Key='Software\[Manufacturer]\[ProductName]'/>
      </Component>
    </Directory>
</Directory>

如果不想覆盖父组件目录,可以省略 Directory 属性。

据我了解,RemoveFolder 组件的 ID 应该与您要删除的目录的 ID 匹配(这对我有用)。

在您的情况下,这将转化为如下内容:

<Directory Id="LocalAppDataFolder">
<!-- perUser case, it is redirected automatically to LocalAppDataFolder -->
    <Directory Id="ProgramFilesHK" Name="$(var.Manufacturer)">
      <Directory Id="APPLICATIONFOLDER" Name="$(var.ApplicationName)">
        <Component Id="CMP_dosomething_exe" Guid="0BA6F4AB-9ED4-4CF2-BDFF-0C95F1DF4BA0" Permanent="no">
          <CreateFolder />
          <RemoveFolder Id="ProgramFilesHK" On="uninstall" />
          <RemoveFolder Id="APPLICATIONFOLDER" On="uninstall" />
            [removed stuff]
        </Component>
      </Directory>
    </Directory>
</Directory>

【讨论】:

  • 正如您在“CMP_downloader_exe”组件中看到的,我已经添加了 RemoveFolder。但是该文件夹没有被删除:(
  • 我的错。我已经更新了我的回复。希望这可以帮助。 WIX 工具集文档中有一个关于卸载快捷方式的部分,我发现它在设置我们最新的安装程序项目时很有用。 wixtoolset.org/documentation/manual/v3/howtos/…
  • 我在卸载日志中看到几行 - 但我不明白:MSI (s) (B8:88) [12:27:46:826]:不允许卸载组件:{439DAE58- 5DE5-4A45-952E-05956D5B4A49} 因为另一个客户端存在
  • 这可能是由于之前的安装引用了组件/GUID。检查 regedit 中的 GUID,看起来你应该在那里找到 CMP_StartMenuShortcut。
  • 我清除了连接到我的应用程序的每个注册表项,现在它可以很好地卸载所有内容。谢谢你们! :)
猜你喜欢
  • 2020-12-15
  • 2017-09-25
  • 2019-07-19
  • 2011-02-14
  • 1970-01-01
  • 2018-08-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多