在有无法启动的服务后继续 Wix 设置 [英] Continue the Wix setup after having a service that could not start

查看:25
本文介绍了在有无法启动的服务后继续 Wix 设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个设置,其中有一项我们尝试安装和运行的服务.

We have a setup in which we have a service that we try to install and run.

由于某种原因,服务无法启动(由于端口已在使用中).这对我们来说并不重要,不应停止设置.

For some reason, the service cannot start(due to a port already in use). This isn't critical for us and should not stop the setup.

服务声明如下:

<DirectoryRef Id="BIN">
  <Component Id="MyService" Guid="*" SharedDllRefCount="yes">
    <File Id="MyService.exe" Name="MyService.exe" KeyPath="yes" Vital="no" Compressed="default" DiskId="1" Source="$(var.DirDotfuscated)\MyService.exe" />
    <ServiceControl Id="Install" Name="MyService" Start="install" Stop="install" />
    <ServiceControl Id="Uninstall" Name="MyService" Stop="uninstall" Remove="uninstall" />
    <ServiceInstall Id="NewServiceInstall2" Name="MyService" DisplayName="My Service" Type="ownProcess" Interactive="no" Start="auto" ErrorControl="normal" Description="My service" Vital="no" />
  </Component>
  <Component Id="Xms_HostService_Files" Guid="*" SharedDllRefCount="yes">
    <File Id="MyService.exe.config" Name="MyService.exe.config" Vital="no" Compressed="default" DiskId="1" Source="$(var.DirDotfuscated)\MyService.exe.config" />
    <File Id="MyServiceCommon.dll" Name="MyServiceCommon.dll" Vital="no" Compressed="default" DiskId="1" Source="$(var.DirDotfuscated)\MyServiceCommon.dll" />
    <File KeyPath="yes" Id="MyServiceCore.dll" Name="MyServiceCore.dll" Vital="no" Compressed="default" DiskId="1" Source="$(var.DirDotfuscated)\MyServiceCore.dll" />
  </Component>
</DirectoryRef>

当我们执行设置时,我们得到这个错误:

When we execute the setup, we get this error:

然后,我们只能选择重试(也会失败)或取消(停止设置).

And then, we only have the option to Retry(which will also fail) or cancel(that stops the setup).

我们尝试了很多东西(只放置 serviceInstall,不放置 serviceControl,...)但在某些时候我们总是有错误.

We tried so many things(only put serviceInstall, not serviceControl, ...) but at some point we always have an error.

我们应该如何管理这个?

How should we manage this?

推荐答案

Attempted Answer(无能力测试):

如果您将 ServiceControl 元素的 Wait 属性 设置为no"会发生什么?我目前没有要测试的服务 exe,但我相信它可以按您的意愿工作.

What happens if you set the ServiceControl element's Wait attribute to "no"? I don't have a service exe to test with at the moment, but I believe that could work as you intend it.

出于可靠性原因,通常应该避免自定义操作,但另一方面 - 如果您确实需要一些特殊的东西 - 这就是它们的用途.不过,请准备好应对源自自定义操作的大多数部署问题:为什么在我的 WiX/MSI 设置中限制使用自定义操作是个好主意?

Custom actions should generally be avoided for reliability reasons, but on the other hand - if you do need something special - that's what they are there for. Be prepared for most deployment problems to originate from your custom actions though: Why is it a good idea to limit the use of custom actions in my WiX / MSI setups?

一些进一步的建议(没有被要求:-)):

Some further advice (which was not asked for :-) ):

  1. 您不应使用一个组件安装多个二进制文件.出于多种原因,您应该为每个组件使用一个文件.Windows Installer 最佳实践明确规定每个组件只能使用一个二进制文件,但在我看来,您通常应该为每个文件使用一个组件,以便进行小规模升级和修补,并使自我修复更加可靠.
    • 为了更好地理解组件引用计数:更改我的组件wix 中的 GUID?
    • 通过消除硬编码 GUID,您可以利用 WiX 先进的自动 GUID 创建概念.如果绝对安装路径更改,这将更改组件 GUID.这是组件引用计数的正确行为.自动魔法.您可以设置 Guid="*" 或完全省略 Guid 属性.一些安装位置需要硬编码的 GUID - WiX 编译器会警告您并解释原因.
  1. You should not install multiple binaries with one component. You should use one file per component for many reasons. Windows Installer best practice specifically dictates to have only one binary per component, but in my opinion you should use one component per file in general to make minor upgrades and patching possible, and self-repair more reliable.
    • To better understand component reference counting: Change my component GUID in wix?
    • By eliminating hard-coded GUIDs you can take advantage of WiX's advanced auto-GUID creation concept. This will change the component GUID if the absolute installation path changes. This is correct behavior for component reference counting. Auto-magic. You either set Guid="*" or just leave out the Guid attribute entirely. A few installation locations need a hard coded GUID - the WiX compiler will warn you and explain why.
  • 您可以像在主安装文件夹层次结构中添加一个包含应用程序主要(和次要?)版本的子文件夹一样简单:"Program Files\MyCompany\MySoftware\5"Program Files\MyCompany\MySoftware".
  • 我只会将主要版本添加到路径中,并在应用程序的整个生命周期内保持安装路径稳定,然后在您想断开与以前安装程序的链接以获取主要新软件版本时增加(例如,如果您想安装两个版本并排 - 您的应用程序必须构建为正确处理此问题,即不会覆盖两个版本中注册表中的共享设置等...)

只是一个快速的内联示例(与上面的链接相同 - 检查它),这是安装具有默认属性/参数的普通文件所需的全部 - 所有其他属性默认良好 -除非你想覆盖某些东西:

Just a quick sample inline (same as in link above - check it out), this is all that is required to install a normal file with default attributes / parameters - all other attributes default well - unless you want to override something:

<Component>
  <File Source="..\File.dll" />
</Component>

<小时>

一些链接:


Some links:

  • Windows Installer Best Practices (full list).
  • Windows Installer Best Practices - Organizing Applications into Components (specifically for component creation).
  • When component reference counting has gone haywire (missing files after upgrades, unexpected removal of shared files on uninstall, etc...): WiX 3.8: Two MSI using the same registry values. How to delete registry values only if both MSI are uninstalled?

这篇关于在有无法启动的服务后继续 Wix 设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆