I am trying to run heat.exe to harvest a folder. The folder contains 3 sub folders, but I want to ignore one of them 'config'. I tried the following as said in this answer How can I exclude SVN files from harvesting with heat (WiX)?:
<xsl:stylesheet version="1.0"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:wi="http://schemas.microsoft.com/wix/2006/wi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl wi">
<xsl:output method="xml" indent="yes"/>
<!-- default copy all -->
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<!-- Search directories for the components that will be removed. -->
<xsl:key name="config-search" match="wi:Directory[@Name = 'config']" use="descendant::wi:Component/@Id" />
<!-- Remove directories. -->
<xsl:template match="wi:Directory[@Name='config']" />
<!-- Remove componentsrefs referencing components in those directories. -->
<xsl:template match="wi:ComponentRef[key('config-search', @Id)]" />
<!-- Get the right sourceDir for the files -->
<xsl:template match="wi:File/@Source">
<xsl:attribute name="{name()}">
<xsl:variable name="sourceDirStart" select="substring-before(., '\')"/>
<xsl:variable name="sourceDirEnd" select="substring-after(., '\')" />
<xsl:value-of select="concat($sourceDirStart, '\', $sourceDirEnd)" />
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
But this doesn't work. Can someone point my mistake here?
You didn't say exactly what does not seem to work. This part (excluding an entire directory) works for me:
<!-- Search directories for the components that will be removed. -->
<xsl:key name="config-search" match="wi:Directory[@Name = 'config']" use="descendant::wi:Component/@Id" />
<!-- Remove directories. -->
<xsl:template match="wi:Directory[@Name='config']" />
<!-- Remove componentsrefs referencing components in those directories. -->
<xsl:template match="wi:ComponentRef[key('config-search', @Id)]" />
Perhaps you're referencing another .xslt
file when invoking heat.exe
by mistake?
I'm not sure what you wanted to achieve using the <xsl:template match="wi:File/@Source">
part, but that does not appear to do anything here. You may want to look at the -var
command line option of Heat.
Also, you seem to have multiple references to http://schemas.microsoft.com/wix/2006/wi
in your XSLT, I'm not sure that this is intentional.