10
votes

I have a lot files to harvest in a per user install project in wix.

I used heat.exe to harvest the file, but each file in one component has its own keypath property, while my files will copy to "app data" so it has to use a registry key under HKCU as its KeyPath, so I have to change each item in the XML file.

Can it be done by heat.exe? I have thousands of files to harvest, it is terrible to fix it manually.

2

2 Answers

7
votes

Use this xslt to customize KeyPath item for nodes that have child nodes.

<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:ComponentGroup/wix:Component'>
        <xsl:copy>
            <xsl:apply-templates select="@*"/>
            <xsl:attribute name="KeyPath">
            <xsl:text>no</xsl:text>
            </xsl:attribute>
            <xsl:apply-templates select="node()"/>
        </xsl:copy>
    </xsl:template>
</xsl:stylesheet>

derived from @KirillPolishchuk 's answer https://stackoverflow.com/a/8035049/483588

1
votes

As far as I know, heat doesn't support this out-of-the-box. However, you can apply an XSL template to the heat output and tweak the final wxs file the way you'd like. See -t: switch of heat.exe for more details.