【问题标题】:WiX 3.5 Install Service from Heat, Need from Custom Action?WiX 3.5 从 Heat 安装服务,需要自定义操作?
【发布时间】:2011-10-24 15:25:47
【问题描述】:

我有一个 VS2010 WiX 项目,其中包含一个主 .wxs 文件和一个空 .wxs 文件。空的 .wxs 在项目的预构建事件中被覆盖,使用 heat.exe 从控制台 exe 中获取所有内容。该 exe 具有 InstallUtil 挂钩,并且在 VS 安装项目的日子里,该 exe 被安装为服务。

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

我认为自定义操作不是进行服务安装的最佳方式,因此我正在尝试 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" />
    ....

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

谢谢。

【问题讨论】:

标签: xslt wix windows-installer custom-action wix3.5


【解决方案1】:

为要使用 Heat 收集的文件创建一个暂存目录。将服务 .exe 分开,以便您可以手动编写 ServiceInstall。

【讨论】:

  • Heat 正在查看服务输出 bin\debug 目录。我希望有一种方法可以从 Heat 中排除文件模式。唔。也许有一种方法可以使用 XSL 删除 exe 文件,这样我就可以将它保存在我的主 wxs 中?
  • 这就是为什么我建议创建一个临时目录,这样您就可以控制 Heat 正在收集什么,而无需走 XSL 路线。
  • @dani-carbonell 提供了一个similar answer - 同时避免了复杂的转换和暂存目录。
【解决方案2】:

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

我通过使用 XSL 将ServiceInstallServiceControl 元素添加到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>

【讨论】:

  • 要完全匹配二进制文件(如果你有一个同名的 app.config),试试这个匹配行:
猜你喜欢
  • 1970-01-01
  • 2019-02-22
  • 1970-01-01
  • 1970-01-01
  • 2013-04-26
  • 1970-01-01
  • 2011-03-15
  • 2016-07-01
  • 2013-10-16
相关资源
最近更新 更多