如何在使用 WiX 工具集(MSI 安装程序)卸载期间停止服务?
How do I stop a service during uninstall with WiX Toolset (MSI Installer)?
我正在使用 WiX 工具集创建 MSI 安装程序。这将安装一个 Java 应用程序,该应用程序具有作为服务安装的本机包装器。
我已经安装好了,但是当我尝试卸载它时,重启管理器检测到正在使用的文件并显示一个对话框,提示需要重启。
Windows 服务运行本机包装程序 bin\wrapper-windows-x86-64.exe
。这个的组件配置是:
<DirectoryRef Id="bin97543xxxx">
<Component Guid="cb21cd16-4bb9-4e57-a13c-4d064f01cd43" Id="bin_wrapper_windows_x86_64_exe189026768">
<File KeyPath="yes" Source="bin\wrapper-windows-x86-64.exe" DiskId="1" Name="wrapper-windows-x86-64.exe" Id="fl_bin_wrapper_windows_x86_64_exe189026768"/>
<RemoveFile Name="wrapper.log" On="uninstall" Id="rm_fl_bin_wrapper_log123456789"/>
<ServiceInstall Name="Test App" Description="Test App" Arguments="-s "..\conf\wrapper.conf" wrapper.console.flush=true" Type="ownProcess" Vital="yes" Start="auto" Account="LocalSystem" ErrorControl="ignore" Interactive="no"/>
<ServiceControl Id="StartService" Name="Test App" Start="install" Stop="both" Remove="uninstall" Wait="yes"/>
</Component>
</DirectoryRef>
此本机包装器将启动 JVM java.exe
以及一些其他 JAR 和本机 DLL。这些 JAR 和 DLL 被定义为单独的组件,例如:
<DirectoryRef Id="bin_wrapper_lib172428748">
<Component Guid="91ea3118-769e-4100-80a2-f09a586500a5" Id="bin_wrapper_lib_wrapper_jar565349582">
<File Source="bin\wrapper\lib\wrapper.jar" DiskId="1" Name="wrapper.jar" Id="fl_bin_wrapper_lib_wrapper_jar565349582"/>
</Component>
</DirectoryRef>
当我尝试卸载该程序时,它检测到 java.exe
正在使用的文件,即使服务停止时它也会停止 JVM。我已经通过在尝试卸载之前手动停止服务来验证这一点。还要注意的是,如果我继续,那么所有文件都会被成功删除,只有 Windows 服务仍然存在(但标记为已删除)。 MSI 日志显示:
Action start 15:48:40: InstallValidate.
...
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Detected that application with id 3636, friendly name 'java.exe', of type RmCritical and status 1 holds file[s] in use.
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.
...
MSI (s) (AC:68) [15:48:59:078]: RESTART MANAGER: The user chose to go on with the installation, although a reboot will be required.
...
The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.
我在 SO 和 WiX 工具集用户邮件列表上看到了一些类似的问题,但没有任何帮助。很多人都在尝试使用自定义操作,并被告知要使用我已经在使用的 ServiceControl。
我还看到有人提到 "files in use logic",我认为这是重启管理器正在做的事情。有人建议使用 ServiceControl 元素将相关文件添加到组件中,但这里似乎不正确(或者至少我不确定该怎么做,并且仍然遵循有关分离组件的最佳实践)。
任何人都可以指出正确的方向吗?
可能是相关的 post - WiX: Avoid showing files-in-use dialog and just prompt for reboot at end of install
设置 MSIRESTARTMANAGERCONTROL=禁用。如果这不起作用,请从您的 MSI 中删除 FileInUse 对话框 ;)
我正在使用 WiX 工具集创建 MSI 安装程序。这将安装一个 Java 应用程序,该应用程序具有作为服务安装的本机包装器。
我已经安装好了,但是当我尝试卸载它时,重启管理器检测到正在使用的文件并显示一个对话框,提示需要重启。
Windows 服务运行本机包装程序 bin\wrapper-windows-x86-64.exe
。这个的组件配置是:
<DirectoryRef Id="bin97543xxxx">
<Component Guid="cb21cd16-4bb9-4e57-a13c-4d064f01cd43" Id="bin_wrapper_windows_x86_64_exe189026768">
<File KeyPath="yes" Source="bin\wrapper-windows-x86-64.exe" DiskId="1" Name="wrapper-windows-x86-64.exe" Id="fl_bin_wrapper_windows_x86_64_exe189026768"/>
<RemoveFile Name="wrapper.log" On="uninstall" Id="rm_fl_bin_wrapper_log123456789"/>
<ServiceInstall Name="Test App" Description="Test App" Arguments="-s "..\conf\wrapper.conf" wrapper.console.flush=true" Type="ownProcess" Vital="yes" Start="auto" Account="LocalSystem" ErrorControl="ignore" Interactive="no"/>
<ServiceControl Id="StartService" Name="Test App" Start="install" Stop="both" Remove="uninstall" Wait="yes"/>
</Component>
</DirectoryRef>
此本机包装器将启动 JVM java.exe
以及一些其他 JAR 和本机 DLL。这些 JAR 和 DLL 被定义为单独的组件,例如:
<DirectoryRef Id="bin_wrapper_lib172428748">
<Component Guid="91ea3118-769e-4100-80a2-f09a586500a5" Id="bin_wrapper_lib_wrapper_jar565349582">
<File Source="bin\wrapper\lib\wrapper.jar" DiskId="1" Name="wrapper.jar" Id="fl_bin_wrapper_lib_wrapper_jar565349582"/>
</Component>
</DirectoryRef>
当我尝试卸载该程序时,它检测到 java.exe
正在使用的文件,即使服务停止时它也会停止 JVM。我已经通过在尝试卸载之前手动停止服务来验证这一点。还要注意的是,如果我继续,那么所有文件都会被成功删除,只有 Windows 服务仍然存在(但标记为已删除)。 MSI 日志显示:
Action start 15:48:40: InstallValidate.
...
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Detected that application with id 3636, friendly name 'java.exe', of type RmCritical and status 1 holds file[s] in use.
MSI (s) (AC:68) [15:48:40:424]: RESTART MANAGER: Did detect that a critical application holds file[s] in use, so a reboot will be necessary.
...
MSI (s) (AC:68) [15:48:59:078]: RESTART MANAGER: The user chose to go on with the installation, although a reboot will be required.
...
The setup must update files or services that cannot be updated while the system is running. If you choose to continue, a reboot will be required to complete the setup.
我在 SO 和 WiX 工具集用户邮件列表上看到了一些类似的问题,但没有任何帮助。很多人都在尝试使用自定义操作,并被告知要使用我已经在使用的 ServiceControl。
我还看到有人提到 "files in use logic",我认为这是重启管理器正在做的事情。有人建议使用 ServiceControl 元素将相关文件添加到组件中,但这里似乎不正确(或者至少我不确定该怎么做,并且仍然遵循有关分离组件的最佳实践)。
任何人都可以指出正确的方向吗?
可能是相关的 post - WiX: Avoid showing files-in-use dialog and just prompt for reboot at end of install
设置 MSIRESTARTMANAGERCONTROL=禁用。如果这不起作用,请从您的 MSI 中删除 FileInUse 对话框 ;)