service - WIX:使用运行器和多 dll 安装服务
问题描述
我正在开发一个 Wix 安装程序,它应该基于同一个运行器安装多个服务。这是一些将由跑步者加载的 dll。使用 sc.exe,这在我的测试系统上运行良好。现在我的问题是,我可以为此使用标准的 Wix ServiceInstall 吗?我只有一个 runner.exe,我不确定如何在 XML 中编写它。还是自定义操作是正确的方式?
谢谢!!
解决方案
ServiceInstall 和 ServiceControl 元素不会出现在文件元素之后,但它们是 Component 元素上的子元素。它们针对恰好是 File 元素的组件的键路径。您可以轻松地将多个服务定义在指向同一个可执行文件的单个组件中。
<Component Id="c1" Guid="dbc1b8dd-14e1-380f-5793-4a746fa0c5c5">
<File Id="f1" Source="$(var.SourceDir)\TestService.exe" KeyPath="yes" />
<ServiceInstall Id="si1" Name="TestService1" DisplayName="TestService1 Service" Description="TestService1 Service" ErrorControl="normal" Start="auto" Type="ownProcess" />
<ServiceControl Id="sc1" Name="TestService1" Start="install" Stop="both" Remove="both" Wait="yes" />
<ServiceInstall Id="si2" Name="TestService2" DisplayName="TestService2 Service" Description="TestService Service" ErrorControl="normal" Start="auto" Type="ownProcess" />
<ServiceControl Id="sc2" Name="TestService2" Start="install" Stop="both" Remove="both" Wait="yes" />
</Component>
要让每个服务表现不同,您必须在服务中编写代码来访问 ServiceBase.ServiceName(可能是 OnStart 方法中的 this.ServiceName)。从这里您可以从不同的程序集中动态加载不同的类。
推荐阅读
- html - 在元素上指定尺寸并以 A4 纸格式显示页面
- sql - 如果外键不存在,则将该字段设置为 NULL
- c++ - 如何创建具有唯一名称的文件?
- java - 如何在 Javers 中更改 commitMetadata 中的作者字段
- spring - 测试休息端点 - Camel 3 + Spring Boot
- javascript - 如何将带有 npm 'docx' 包的图像添加到 word 文档?
- azure-cosmosdb - CosmosClient 与 DocumentClient
- python - 我必须对以块形式读取的不同大小的数据帧执行集合并集并设置差异
- html - 将嵌入视频与页面中心对齐
- android - 从 json 数组放置和排序适配器