12

I'm using the Heat tool to generate Wix markup to include a large number of files and folders in my setup. This was working fine, but I just realized that since I added the source folder to my Subversion repository, Heat wants to include the .svn folders too.

Is there a way to tell Heat not to harvest files or folders that match a given criteria?

I am currently using Wix 3.5.

kaya3
  • 47,440
  • 4
  • 68
  • 97
Alan Spark
  • 8,152
  • 8
  • 56
  • 91

3 Answers3

13

Here is what works for me:

<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">

    <!-- Copy all attributes and elements to the output. -->
    <xsl:template match="@*|*">
        <xsl:copy>
            <xsl:apply-templates select="@*" />
            <xsl:apply-templates select="*" />
        </xsl:copy>
    </xsl:template>

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

    <!-- Create searches for the directories to remove. -->
    <xsl:key name="svn-search" match="wix:Directory[@Name = '.svn']" use="@Id" />
    <xsl:key name="tmp-search" match="wix:Directory[@Name = 'tmp']" use="@Id" />
    <xsl:key name="prop-base-search" match="wix:Directory[@Name = 'prop-base']" use="@Id" />
    <xsl:key name="text-base-search" match="wix:Directory[@Name = 'text-base']" use="@Id" />
    <xsl:key name="props-search" match="wix:Directory[@Name = 'props']" use="@Id" />

    <!-- Remove directories. -->
    <xsl:template match="wix:Directory[@Name='.svn']" />
    <xsl:template match="wix:Directory[@Name='props']" />
    <xsl:template match="wix:Directory[@Name='tmp']" />
    <xsl:template match="wix:Directory[@Name='prop-base']" />
    <xsl:template match="wix:Directory[@Name='text-base']" />

    <!-- Remove Components referencing those directories. -->
    <xsl:template match="wix:Component[key('svn-search', @Directory)]" />
    <xsl:template match="wix:Component[key('props-search', @Directory)]" />
    <xsl:template match="wix:Component[key('tmp-search', @Directory)]" />
    <xsl:template match="wix:Component[key('prop-base-search', @Directory)]" />
    <xsl:template match="wix:Component[key('text-base-search', @Directory)]" />

    <!-- Remove DirectoryRefs (and their parent Fragments) referencing those directories. -->
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('svn-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('props-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('tmp-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('prop-base-search', @Id)]]" />
    <xsl:template match="wix:Fragment[wix:DirectoryRef[key('text-base-search', @Id)]]" />
</xsl:stylesheet>
jbierling
  • 681
  • 6
  • 12
  • +1 This is the same solution I use to filter out code contracts directories – Lukazoid Nov 16 '12 at 09:43
  • 1
    If getting Unresolved reference to symbol errors, change `use="@Id"` to `use="descenddant::wix:Component/@Id"` as mentioned [here](http://stackoverflow.com/a/9163895) – dwp4ge Jan 28 '15 at 16:09
  • 1
    I think a better solution to this problem is given here: https://stackoverflow.com/a/9163895/3418322 – Roger Sanders Jul 06 '17 at 23:21
12

Unfortunately, today you'd have to use an XSL transform to filter out the "noise". This is a feature request for heat.

Rob Mensching
  • 33,834
  • 5
  • 90
  • 130
  • 1
    OK, thanks Rob. It would certainly be useful to be able to do this. – Alan Spark Jul 26 '11 at 08:50
  • 1
    I read your answer and wondered how to apply the XSL on the WXS that Heat.exe generated. So in case someone is looking for it as well, all you need is to use Heat.exe -t flag. See: http://stackoverflow.com/questions/8034798/wix-installer-using-xslt-with-heat-exe-to-update-attributes http://wixtoolset.org/documentation/manual/v3/overview/heat.html – MichaelS Dec 31 '13 at 10:24
1

Subversion 1.7 has been released, and has centralized the metadata storage as a single .svn folder per working copy. Therefore, I suspect your problem will go away if you simply upgrade your SVN client.

Wim Coenen
  • 66,094
  • 13
  • 157
  • 251