微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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>

原文地址:https://www.jb51.cc/windows/372047.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐