【问题标题】:Unable to uninstall the application which is installed using wix installer无法卸载使用 wix 安装程序安装的应用程序
【发布时间】:2019-12-13 21:02:46
【问题描述】:

我使用wix 安装程序为我的c# 应用程序创建了一个安装程序。

安装正常,但我无法卸载该应用程序。我在日志下面看到

MSI (s) (78:AC) [15:32:06:199]: Machine policy value 'Debug' is 0
MSI (s) (78:AC) [15:32:06:199]: ******* RunEngine:
       ******* Product: C:\wix\Installer\\bin\Debug\MyService-Debug-x86.msi
       ******* Action: 
       ******* CommandLine: **********
MSI (s) (78:AC) [15:32:06:207]: Machine policy value 'DisableUserInstalls' is 0
MSI (s) (78:AC) [15:32:06:326]: Note: 1: 2203 2: 
C:\Windows\Installer\inprogressinstallinfo.ipi 3: -2147287038 
MSI (s) (78:AC) [15:32:06:327]: Machine policy value 
'LimitSystemRestoreCheckpointing' is 0 
MSI (s) (78:AC) [15:32:06:327]: Note: 1: 1717 2: My Service (32bit) 
MSI (s) (78:AC) [15:32:06:327]: Note: 1: 2205 2:  3: Error 
MSI (s) (78:AC) [15:32:06:327]: Note: 1: 2228 2:  3: Error 4: SELECT 
`Message` FROM `Error` WHERE `Error` = 1717 
MSI (s) (78:AC) [15:32:06:327]: Calling SRSetRestorePoint API. 
dwRestorePtType: 1, dwEventType: 102, llSequenceNumber: 0, szDescription: 
"Removed My Service (32bit)".
MSI (s) (78:AC) [15:32:06:330]: The System Restore service is disabled. 
Returned status: 1058. GetLastError() returned: 1058
MSI (s) (78:AC) [15:32:06:332]: File will have security applied from OpCode.
MSI (s) (78:AC) [15:32:06:362]: SOFTWARE RESTRICTION POLICY: Verifying 
package --> 'C:\wix\Installer\\bin\Debug\MyService-Debug-x86.msi' against 
software restriction policy
MSI (s) (78:AC) [15:32:06:363]: Note: 1: 2262 2: DigitalSignature 3: 
-2147287038 
MSI (s) (78:AC) [15:32:06:363]: SOFTWARE RESTRICTION POLICY: 
C:\wix\Installer\\bin\Debug\MyService-Debug-x86.msi is not digitally signed
MSI (s) (78:AC) [15:32:06:365]: SOFTWARE RESTRICTION POLICY: 
C:\wix\Installer\\bin\Debug\MyService-Debug-x86.msi is permitted to run at 
the 'unrestricted' authorization level.
MSI (s) (78:AC) [15:32:06:366]: MSCOREE not loaded loading copy from 
system32
MSI (s) (78:AC) [15:32:06:374]: End dialog not enabled
MSI (s) (78:AC) [15:32:06:374]: Original package ==> 
C:\wix\Installer\\bin\Debug\MyService-Debug-x86.msi
MSI (s) (78:AC) [15:32:06:374]: Package we're running from ==> 
C:\Windows\Installer\152e2e.msi

在创建安装程序时,我从没想过数字签名等等。跟签有关系吗?完全迷路了,需要帮助

我什至尝试过使用命令行(管理员模式)运行uninstallation,但没有成功

msiexec.exe /x "C:\wix\Installer\\bin\Debug\MyService-Debug-x86.msi" /L*V "C:\work\wix.log"

它说

已安装此产品的另一个版本。此版本的安装无法继续。要配置或删除此产品的现有版本,请使用控制面板上的添加/删除程序。

我可能必须在卸载之前重新构建安装程序代码。是否有可能与安装程序相关的某些“guid”发生了变化? registry里面有什么我要检查的吗?

用 Wix 代码更新了问题

在我添加自定义操作后问题开始出现。自定义操作的职责是从安装程序获取参数并更新 appsettings.json。但是这个卸载问题不允许我继续实施。

  <Property Id="APPLICATIONLOG.PATHFORMAT"  Secure="yes"/>

  <Binary Id="CustomActionDLL" 
          SourceFile="..\..\Installer\CustomActions\bin\$(var.Configuration)\CustomAction.CA.dll" />

  <CustomAction Id="SetPropertyAppLogPathId"
                Property="SetPropertyAppLogPathProperty"
                Value="APPLICATIONLOG.PATHFORMAT=[APPLICATIONLOG.PATHFORMAT]"/>

  <CustomAction Id="SetPropertyAppLogPathProperty"
                BinaryKey="CustomActionDLL"
                DllEntry="UpdateConfigurationsAction"
                Execute="deferred"
                Return="check"
                Impersonate="no" />

  <InstallExecuteSequence>
    <Custom Action="SetPropertyAppLogPathId" Before="SetPropertyAppLogPathProperty"><![CDATA[NOT Installed]]></Custom>
    <Custom Action="SetPropertyAppLogPathProperty" After="InstallFiles"></Custom>
  </InstallExecuteSequence>

我的自定义操作 c# 代码

public class CustomActions
{
    public static string ApplicationPath { get; private set; }

    [CustomAction]
    public static ActionResult UpdateConfigurationsAction(Session session)
    {
        try
        {
            session.Log("Begin UpdateConfigurationsAction");
            ApplicationPath = session.CustomActionData["APPLICATIONLOG.PATHFORMAT"];
            session.Log("Application Log Path is: " + ApplicationPath);
            return ActionResult.Success;
        }
        catch (Exception e)
        {
            session.Log("Error in UpdateConfigurationsAction  " + e.Message);
            return ActionResult.Failure;
        }

    }
}

问题已解决

问题出在自定义操作上。进行正确的 InstallExecuteSequence 后,它起作用了!

将在解决方案部分更新

【问题讨论】:

  • 你能分享你的wix代码吗?
  • @PavelAnikhouski 更新了 wix 代码。请查看
  • 不确定,但您可能安装了悬空版本。您在 Add / Remove programs 中看到了什么?自定义操作很可能会崩溃,因此卸载会回滚。有一些方法可以解决这个问题,但请先检查上述内容。
  • 为什么在卸载过程中会调用自定义安装?它应该只在安装期间执行。
  • 进行命令行卸载时,您应该始终为 -x 参数指定已安装产品的 ProductCode GUID,例如 msiexec -x {ProductCode}。软件包可能已更改,因此无法卸载。例如,您可以使用 msiinv.exe 找到已安装的 ProductCode,或者只需从卸载注册表项中查找:HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall

标签: wix windows-installer wix3.7


【解决方案1】:

交叉链接How to clean out broken uninstalls.


Microsoft FixIt:在尝试其他任何方法之前,不妨先试试Microsoft FixIt tool 看看是否可以摆脱任何 悬挂装置。如果不成功,请进一步向下检查其他 接近。

Debugging & Logging:接下来根据custom action debugging 修复你在包中的自定义操作(我推荐the Advanced Installer MSI CA debugging video,它速度快,是一个很好的“hello 调试器” "会话)和gathering logging information

对策:最后,也许是add a property to suppress the custom action from running as described here"Adding Condition" 部分)。

  • 这是最简单的 我知道抑制自定义操作在卸载时运行的想法 - 您只需在需要时设置所涉及的属性,以在自定义操作崩溃时抑制它。 >
  • 我会将它用于我的所有自定义操作 - 事实上 - 所以我可以将它们全部抑制(或 可能会一个一个) - 特别是对于您遇到"catch 22" 情况的卸载场景(由于自定义操作错误而无法安装、升级或卸载)。

悬空安装:为了检测所有相关的悬空安装(如果有),您可以使用这种方法:Unable to uninstall program from WiX created MSI(枚举所有具有相同升级代码)。


我现在将添加这些链接,以防你发现那个悬空版本:

在尝试删除卸载时崩溃的 MSI 时,核心问题是涉及多少台计算机?如果只是一个,那么破解缓存的MSI数据库可能是可以接受的,否则你应该创建一个补丁包来修复卸载顺序,然后以正常方式触发卸载。


链接

【讨论】:

    猜你喜欢
    • 2019-05-18
    • 2014-08-11
    • 1970-01-01
    • 1970-01-01
    • 2014-01-31
    • 2021-09-21
    • 1970-01-01
    • 2022-07-23
    • 2021-12-26
    相关资源
    最近更新 更多