代码之家  ›  专栏  ›  技术社区  ›  Zoltan Hernyak

WiX卸载不会卸载任何内容

  •  0
  • Zoltan Hernyak  · 技术社区  · 7 年前

    我对使用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>
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   MOS    7 年前

    在组件元素上,可以添加: RemoveFile、RemoveFolder、removeGistryKey和removegistryValue元素。看见 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>
    

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

    据我所知,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>