我正在使用HeatDirectory来创建源.wxs文件.在拾取目录中有一个exe应该作为服务安装.实际上,如果我自己创建组件,我知道如何安装服务,但我不知道如何在自动生成的组件中包含ServiceInstall.有什么建议吗?
<HeatDirectory DirectoryRefId="Guardian" OutputFile="Source\GuardianSource.wxs" Transforms="Filter.xsl" Directory="..\Setup\C24.Guardian\bin\Debug" PreprocessorVariable="var.GuardianPath" ComponentGroupName="GuardianGroup" ToolPath="$(WixToolPath)" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="true" GenerateGuidsNow="false">
</HeatDirectory>
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="Guardian">
<Component Id="cmp70BEDA00F3161F3FB5E847EB1136B1D5" Guid="*">
<File Id="fil26DCBF1E4218C7363018FBA2CD456633" KeyPath="yes" Source="$(var.GuardianPath)\C24.Guardian.exe" />
</Component>
<Component Id="cmp2EE8126A193FA022ED35FAD8F182E65A" Guid="*">
<File Id="fil785CD681C496EDDAB457E8314C49D686" KeyPath="yes" Source="$(var.GuardianPath)\C24.Guardian.exe.config" />
</Component>
<Component Id="cmp0CC91B457FBC44F978A2AD6B24043DCF" Guid="*">
<File Id="fil2D304D0395599AAAAAF975A2DBFD530F" KeyPath="yes" Source="$(var.GuardianPath)\C24.Guardian.pdb" />
</Component>
<Component Id="cmpFB799FA015274DDBE2C337C60667D2C5" Guid="*">
<File Id="filB9C39B394CAD03F5A1BC3262C61EDDEB" KeyPath="yes" Source="$(var.GuardianPath)\C24.Guardian.vshost.exe" />
</Component>
<Component Id="cmp28C29865AE85B067BCEEBD70EFDB19D5" Guid="*">
<File Id="fil0A756B711769AAD657F306B3A6EA7134" KeyPath="yes" Source="$(var.GuardianPath)\C24.Guardian.vshost.exe.config" />
</Component>
<Component Id="cmp92A715A4BD4B580A6E70362230170428" Guid="*">
<File Id="filBD9D504F303A6EEC9E340E3872BBB0AE" KeyPath="yes" Source="$(var.GuardianPath)\C24.Guardian.vshost.exe.manifest" />
</Component>
<Component Id="cmp8AB6A241FA2D13F296CBD946C9711579" …Run Code Online (Sandbox Code Playgroud) 我使用WiX Toolset编写了一个新的安装程序。看来最佳实践是使用 heat.exe 应用程序运行构建的应用程序文件并自动生成引用以包含在安装程序中。这很棒,但我发现通过使用这种技术,您几乎可以阻止这些文件在其他任何地方发挥作用,除了将它们复制到安装目录的行为之外。这是因为我似乎无法“引用”这些文件来进行其他操作。例如。我想将其中一个文件安装为服务,但ServiceInstall机制似乎不允许您使用收获中引用的内容。另外,我的文件之一是一个 XML 文件,我想根据安装过程中用户的输入进行修改。同样,我似乎无法在XmlConfig机制中使用的收获中引用此文件。
我看过这篇文章,但所选答案实际上并未提供示例。首先,WiX 编译器不允许您在标识符字段中放置“#”符号,因为正如答案帖子所声称的那样,它“不是合法的标识符”。如果您使用收获中的普通 ID,它会抱怨它们已经存在。
这是我的收获 .wxs 文件的片段。
<!-- Xml file I'd like to modify during install -->
<Component Id="cmp78CF3591818BB6F883096F2C98654BA9" Guid="*">
<File Id="fil1532F0BC6EDCE81B25489D872A72339A" KeyPath="yes" Source="$(var.MyApplication.TargetDir)\log.config" />
</Component>
<!-- ... -->
<!-- Application I'd like to install as a service -->
<Component Id="cmp84F0EA671F93094E33AE84FA2A03BA2E" Guid="*">
<File Id="filD4A27A27D20D3D734B279B4F21754836" KeyPath="yes" Source="$(var.MyApplication.TargetDir)\MyService.exe" />
</Component>
Run Code Online (Sandbox Code Playgroud)
对于服务安装,我觉得直观的方式是这样的:
<Component Id="cmp84F0EA671F93094E33AE84FA2A03BA2E">
<File Id="filD4A27A27D20D3D734B279B4F21754836" />
<ServiceInstall
Id="MyServiceID"
Name="MyService"
Type="ownProcess"
Start="auto"
ErrorControl="normal"
Interactive="no">
</ServiceInstall>
<ServiceControl Name="MyService" Id="MyServiceControl" Start="install" Stop="both" Remove="uninstall" …Run Code Online (Sandbox Code Playgroud)