xslt – WiX 3.5从热门安装服务,需要自定义动作吗?

我有一个带有主.wxs文件的VS2010 WiX项目和一个空的.wxs文件.在项目的prebuild事件中覆盖空的.wxs,使用heat.exe从控制台exe收集所有内容. exe有InstallUtil挂钩,在VS安装项目中,exe作为服务安装.

我试图使用< ServiceInstall> WiX中的位,但是当我指定可执行文件和其他元素来安装服务时,light抱怨主.wxs中的.exe与热量生成的.wxs中的.exe之间发生冲突.

我认为自定义操作不是进行服务安装的最佳方式,因此我尝试使用XSL转换来获取我不想要的文件(它是100个中的单个文件).

我的XSL一定有问题,因为它不匹配/过滤.这里是:

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl"
    xmlns:Wix="http://schemas.microsoft.com/wix/2006/wi">

  <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()" />
    </xsl:copy>
  </xsl:template>

<xsl:template match="
        Component[File/@Source='$(var.bindir)\servicehost.exe']"/
</xsl:stylesheet>

我需要撕掉的.wxs的部分看起来像这样:

....
     <Component Id="cmpD64BE1790BFAF0F05DA37558F5D72572" Guid="{6C70DDC8-349B-4B66-A415-DE08E302C2A8}">
                    <File Id="fil24DFDFCA765C9A8BBB8854CE66AED0E8" KeyPath="yes" Source="$(var.bindir)\servicehost.exe" />
                </Component>
    ....
<ComponentRef Id="cmpD64BE1790BFAF0F05DA37558F5D72572" />
    ....

这项工作的最佳方法是什么?

谢谢.

Wix XML元素位于命名空间中,因此您需要在匹配值中指定命名空间.

我通过使用XSL将ServiceInstall和ServiceControl元素添加到由heat生成的片段中解决了同样的问题:

<!-- Add the service install/control entries to mybinary.exe -->
<xsl:template match="wix:Component[contains(wix:File/@Source,'mybinary.exe')]">
    <xsl:copy>
        <xsl:apply-templates select="node() | @*" />
        <wix:ServiceInstall Id="MyServiceInstall" displayName="[SERVICE_NAME]" Description="[SERVICE_DESC]" Name="MyService" Arguments="" ErrorControl="normal" Start="auto" Type="ownProcess" Vital="yes" Account="LocalSystem" />
        <wix:ServiceControl Id="MyServiceControl" Name="MyService" Start="install" Stop="uninstall" Remove="uninstall" />
    </xsl:copy>
</xsl:template>

相关文章

Windows2012R2备用域控搭建 前置操作 域控主域控的主dns:自...
主域控角色迁移和夺取(转载) 转载自:http://yupeizhi.blo...
Windows2012R2 NTP时间同步 Windows2012R2里没有了internet时...
Windows注册表操作基础代码 Windows下对注册表进行操作使用的...
黑客常用WinAPI函数整理之前的博客写了很多关于Windows编程的...
一个简单的Windows Socket可复用框架说起网络编程,无非是建...