在 wix 安装程序中使用 cutomAction DriverPackageInstall 安装驱动程序

Installing driver using cutomAction DriverPackageInstall in wix installer

我使用 DriverPackageInstall 安装驱动程序,并在 wix 安装程序中卸载 DriverPackageUnInstall。它工作得很好,如果安装和卸载驱动程序版本 1.0.0.0。

但是当我安装 1.0.0.0 并升级 1.2.0.0 时。用 1.2.0.0 二进制文件替换驱动程序效果很好。

但是我卸载的时候驱动并没有卸载,查看日志发现卸载成功DriverPackageUnInstall return 0,同样logContext.difxError也是0。

无法弄清楚为什么没有卸载驱动程序。

 <Custom Action='InstallDriverAction'
         After='InstallFiles'>NOT Installed</Custom>

 <Custom Action='UninstallDriverAction'
         After='InstallInitialize'>
                Installed AND NOT UPGRADINGPRODUCTCODE</Custom>

一个观察结果是版本 1.0.0.0 的驱动程序、cat、inf 仍然存在于 DRVSTORE,并且删除了 1.2.0.0 的驱动程序。

任何帮助将不胜感激。

谢谢

 <Custom Action='UninstallDriverAction'
         After='InstallInitialize'>
                Installed AND NOT UPGRADINGPRODUCTCODE</Custom>

条件看起来不对。它目前显示 "uninstall the driver if it is installed, except during a major upgrade"。您可能在重大升级期间卸载旧版本的驱动程序,因此应该删除AND NOT UPGRADINGPRODUCTCODE

条件的Installed部分也是错误的。实际上这会在维修时卸载驱动程序!有人可能会争辩说,卸载驱动程序然后重新安装它可能很有用,希望能修复一些错误。但在当前状态下,驱动程序不会在修复期间再次安装,因为属性仅在获取阶段检查一次,并且不会在安装的执行阶段更新。

我的建议:

 <Custom Action='InstallDriverAction'
         After='InstallFiles'>NOT Installed OR REINSTALL</Custom>

 <Custom Action='UninstallDriverAction'
         After='InstallInitialize'>
                REMOVE~="ALL" OR REINSTALL</Custom>

第一个条件非常标准:如果尚未安装驱动程序,请安装驱动程序或者这是重新安装(也称为修复)。

第二个条件是在任何这些情况下卸载驱动程序:

  • 定期卸载期间
  • 在重大升级的情况下卸载期间。这需要对 RemoveExistingProducts standard action so the uninstall of the existing version will be done entirely before installing the new version. When using the WiX MajorUpgrade 元素进行早期排序,默认值为 Schedule="afterInstallValidate",这正是这样做的。
  • 在重新安装(也称为修复)期间。我还不确定这是否是个好主意,请参阅下面的评论。