Windows 安装期间 Wix 能否跳过 InstallValidate

Can Wix skip InstallValidate during installation on Windows

我正在使用 Wix 将应用服务控制器、应用服务、应用核心和应用托盘打包到安装程序中。在升级期间,安装程序会执行一个 Installvalidate 步骤,该步骤抱怨我所有进程正在使用的文件。

安装输出如下

Info 1603.The file C:\Program Files\app\app-service-controller.exe is being held in use by the following process: Name: app-service-controller, Id: 26308, Window Title: '(not determined yet)'.  Close that application and retry.
Info 1603.The file C:\Program Files\app\app-service.exe is being held in use by the following process: Name: app-service, Id: 26028, Window Title: '(not determined yet)'.  Close that application and retry.
Info 1603.The file C:\Program Files\app\app-core.exe is being held in use by the following process: Name: app-core, Id: 25932, Window Title: '(not determined yet)'.  Close that application and retry.
Info 1603.The file C:\Program Files\app\app-tray.exe is being held in use by the following process: Name: app-tray, Id: 25856, Window Title: '(not determined yet)'.  Close that application and retry.
MSI (s) (A0:30) [12:43:46:999]: 4 application(s) had been reported to have files in use.
MSI (c) (04:48) [12:43:47:000]: File In Use: -app-service-controller- Window could not be found. Process ID: 26308
MSI (c) (04:48) [12:43:47:000]: File In Use: -app-service- Window could not be found. Process ID: 26028
MSI (c) (04:48) [12:43:47:000]: File In Use: -app-core- Window could not be found. Process ID: 25932
MSI (c) (04:48) [12:43:47:001]: File In Use: -app-tray- Window could not be found. Process ID: 25856
MSI (c) (04:48) [12:43:47:001]: No window with title could be found for FilesInUse

问题是需要很长时间,大约 5-10 分钟,才能通过那个阶段,然后重新安装一切正常。有什么方法可以让它更快甚至跳过它吗?

与应用服务相关的Wix代码

<ServiceInstall
    Id="ServiceInstall" Name="App-Service-Controller" DisplayName="$(var.Name)"
    Description="Controls the $(var.Name) foreground processes."
    Type="ownProcess" Start="auto" ErrorControl="normal">
    <util:ServiceConfig
        FirstFailureActionType='restart'
        SecondFailureActionType='restart'
        ThirdFailureActionType='restart'
        RestartServiceDelayInSeconds='1'
        ResetPeriodInDays='1'/>
    </ServiceInstall>
<ServiceControl
    Id="ServiceControl" Name="App-Service-Controller"
    Start="install" Stop="both" Remove="uninstall" Wait="yes"/>

相关帖子:

MSI: How a Service is stopped on uninstall during InstallValidate - could that work anyway?

如有错误请指正

  • 无法绕过 InstallValidate。 Wix 会给你一个错误 说这是必需的。
  • 您不能在 InstallValidate 之前重新排序 StopService 步骤。
  • 您不能 运行 在 InstallValidate 之前以管理员身份执行自定义操作。

所以我最终创建了一个可以在 InstallValidate 之前执行的新进程。在该过程中,我使用 RPC 告诉我的服务停止。