WiX 3.5从Heat安装服务,是否需要自定义操作? [英] WiX 3.5 Install Service from Heat, Need from Custom Action?

查看:95
本文介绍了WiX 3.5从Heat安装服务,是否需要自定义操作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a VS2010 WiX project with a main .wxs file and an empty .wxs file. The empty .wxs is overwritten in the prebuild event of the project, using heat.exe to harvest everything from a console exe. The exe has InstallUtil hooks, and in the days of VS setup project the exe was installed as a Service.

我尝试使用< WiX中的ServiceInstall> 位,但是当我指定可执行文件和其他元素来安装Service时,light抱怨主.wxs中的.exe与heat。生成的.wxs。

I tried to use the <ServiceInstall> bits in WiX, but when I specified the executable and other elements to get the Service installed, light complained of a collision between the .exe in the main .wxs and the .exe in the heat-generated .wxs.

我认为自定义操作不是执行服务安装的最佳方法,因此我正在尝试XSL转换以获取我不知道的文件想要(这是100个文件中的一个)。

I think Custom Action is not the best way to do the service installation, so I am attempting XSL transformation to get the file out that I don't want (it's a single file out of 100).

我的XSL必须存在问题,因为它不匹配/过滤。在这里是:

My XSL must have a problem, because it is not matching/filtering. Here it is:

<?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部分看起来像这样:

The parts of the .wxs I need to rip out look like this:

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

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

What is the best way to make this work?

谢谢。

推荐答案

Wix XML元素位于名称空间中,因此您需要在 match 值中指定名称空间。

The Wix XML elements are in a namespace, so you need to specify the namespace in the match value.

我通过使用XSL添加了 ServiceInstall ServiceControl 元素到 heat 生成的片段中:

I solved the same problem by using XSL to add in the ServiceInstall and ServiceControl elements to the fragment generated by 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>

这篇关于WiX 3.5从Heat安装服务,是否需要自定义操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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