[wix-users] Applying patch with heat

Helge Kruse Helge.Kruse at gmx.net
Fri Jan 13 08:59:42 PST 2017


Am 12.01.2017 um 16:29 schrieb Phill Hogland:
> With regard to #2, this is not a direct answer but code I use to set some attributes.

But this was very helpful. I'm still learning XSLT but got a basic idea
how this file affects the processing. Useful is Michael Kays book "XSLT"
2nd edition.

To apply the transforms (exclude files by extension, add attributes to
files selected by extension) I use this XSLT file.

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

  <xsl:output method="xml" />

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

  <!-- Special case: Skip components by file type .PDB .WSC -->
  <xsl:key name="pdb-search"
match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
  <xsl:template match="wix:Component[key('pdb-search', @Id)]" />

  <xsl:key name="wsc-search"
match="wix:Component[contains(wix:File/@Source, '.wsc')]" use="@Id" />
  <xsl:template match="wix:Component[key('wsc-search', @Id)]" />

  <!-- Special case: Add attribute to DLLs because these are .NET
assemblies to put them to GAC. -->
  <xsl:template match="wix:File[contains(@Source,'.dll')]">
    <File>
      <xsl:copy-of select="@*" />
      <xsl:attribute name="Assembly">
        <xsl:text>.net</xsl:text>
      </xsl:attribute>
    </File>
  </xsl:template>

  <!-- Add a comment at root node. -->
  <xsl:template match="/">
    <xsl:comment>!!!DO NOT EDIT!!! Generated by HarvestDirectory
target.</xsl:comment>
    <xsl:apply-templates />
  </xsl:template>

</xsl:stylesheet>


It would be nice to have this built in into heat, but the possibility to
define a custom transform is much more flexible. E.g. the selection of
components should be difficult to configure.

Thanks for the help!

Regards,
Helge



More information about the wix-users mailing list