WiX安装程序:将xslt与heat.exe结合使用以更新属性 [英] WiX Installer: using xslt with heat.exe to update attributes

查看:75
本文介绍了WiX安装程序:将xslt与heat.exe结合使用以更新属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为Windows服务创建WiX安装程序,并且已经阅读到我需要将所有文件的KeyPath设置为"no",但WiX脚本中的.exe除外. 我目前正在使用Heat.exe生成目录和文件结构,这是我的命令:

I am trying to create a WiX installer for a Windows service, and I have read that I need to set the KeyPath to "no" for all my files, with the exception of the .exe in my WiX script. I am currently generating my Directory and file structure using Heat.exe here is my command:

"$(WIX)bin\heat.exe" dir $(SolutionDir)EmailGenerationService\bin\PROD 
                    -cg EmailGenFiles -gg -scom -sreg -sfrag -srd -suid 
                    -dr INSTALLLOCATION -var var.FileSource 
                    -t $(Projectdir)KeyPathTransform.xslt 
                    -out $(ProjectDir)DirectoryAndFileComponents.wxs

我打算用DirectoryAndFileComponents.wxs文件中的Keypath=no更新所有文件元素. 来自热量的输出示例为:

It is my intention to update all the file elements with Keypath="no" in my DirectoryAndFileComponents.wxs file. A sample of the output from heat is:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <DirectoryRef Id="INSTALLLOCATION">
      <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}">
        <File Id="Dollar.Common.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.dll" />
      </Component>
      <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}">
        <File Id="Dollar.Common.Exceptions.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" />
      </Component>
      <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}">
        <File Id="Dollar.Common.Exceptions.pdb" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" />
      </Component>
      <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}">
        <File Id="Dollar.Common.Logging.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Logging.dll" />
      </Component>

这是我传递给热量进行转换的XSLT:

Here is the XSLT I am passing to heat to perform the transformation:

<?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/wix"
            xmlns:my="my:my">

  <xsl:output method="xml" indent="no"/>

  <xsl:strip-space elements="*"/>

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:template match='/wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Component/wix:File[@Id and not (@Id="EmailGenerationService.exe")]'>
    <xsl:attribute name="KeyPath">
          <xsl:value-of select="no"/>
    </xsl:attribute>
  </xsl:template>
</xsl:stylesheet>

基于该站点上的其他帖子以及其他地方,我已经尝试了很多变体,但是到目前为止,仍无法使heat.exe创建的文件具有KeyPath ="no".

I have tried quite a few variations of this based on other posts on this site and else where, but as yet have been unable to get the file created by heat.exe to have KeyPath="no".

我缺少明显的东西吗?

Am I missing something obvious?

推荐答案

您有两个不同的已定义命名空间:

You have two different defined namespaces:

  1. 在XML中:http://schemas.microsoft.com/wix/2006/wi
  2. 在XSLT中:http://schemas.microsoft.com/wix/2006/wix
  1. In XML: http://schemas.microsoft.com/wix/2006/wi
  2. In XSLT: http://schemas.microsoft.com/wix/2006/wix

据我所知,WiX的正确命名空间是http://schemas.microsoft.com/wix/2006/wi.因此,您应该更改XSLT.

As far as I know, correct namespace for WiX is http://schemas.microsoft.com/wix/2006/wi. So you should change your XSLT.

XSLT:

<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"
            xmlns:my="my:my">

    <xsl:output method="xml" indent="yes" />

    <xsl:strip-space elements="*"/>

    <xsl:template match="@*|node()">
        <xsl:copy>
            <xsl:apply-templates select="@*|node()"/>
        </xsl:copy>
    </xsl:template>

    <xsl:template match='wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Component/wix:File[@Id and not (@Id = "EmailGenerationService.exe")]'>
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:attribute name="KeyPath">
                <xsl:text>no</xsl:text>
            </xsl:attribute>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

输入XML:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="INSTALLLOCATION">
            <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}">
                <File Id="Dollar.Common.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.dll" />
            </Component>
            <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}">
                <File Id="Dollar.Common.Exceptions.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" />
            </Component>
            <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}">
                <File Id="Dollar.Common.Exceptions.pdb" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" />
            </Component>
            <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}">
                <File Id="Dollar.Common.Logging.dll" KeyPath="yes" Source="$(var.FileSource)\Dollar.Common.Logging.dll" />
            </Component>
        </DirectoryRef>
    </Fragment>
</Wix>

输出XML:

<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Fragment>
    <DirectoryRef Id="INSTALLLOCATION">
      <Component Id="Dollar.Common.dll" Guid="{2BCD0767-2383-47CF-B1BF-325FA4A3264F}">
        <File Id="Dollar.Common.dll" Source="$(var.FileSource)\Dollar.Common.dll" KeyPath="no" />
      </Component>
      <Component Id="Dollar.Common.Exceptions.dll" Guid="{B7238091-76D1-42F5-A3B4-A539DFF3BD92}">
        <File Id="Dollar.Common.Exceptions.dll" Source="$(var.FileSource)\Dollar.Common.Exceptions.dll" KeyPath="no" />
      </Component>
      <Component Id="Dollar.Common.Exceptions.pdb" Guid="{43711979-747D-49C9-BAE4-ECD44FAF5E67}">
        <File Id="Dollar.Common.Exceptions.pdb" Source="$(var.FileSource)\Dollar.Common.Exceptions.pdb" KeyPath="no" />
      </Component>
      <Component Id="Dollar.Common.Logging.dll" Guid="{59F9ABF3-5F68-410C-BC96-0556282F1E04}">
        <File Id="Dollar.Common.Logging.dll" Source="$(var.FileSource)\Dollar.Common.Logging.dll" KeyPath="no" />
      </Component>
    </DirectoryRef>
  </Fragment>
</Wix>

这篇关于WiX安装程序:将xslt与heat.exe结合使用以更新属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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