10

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.

1

2 Answers 2

7

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

Sign up to request clarification or add additional context in comments.

Comments

1

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.

2 Comments

thanks Yan, could you give me more info? you mean -t can fix my problem? could tell me more? i can not find the answer in its official document.
See the help text for heat.exe. You can specify -t:transform.xslt and in that transform do any modifications to the XML generated initially by heat.exe. For instance, in your case, you can create a template which "matches" to the component elements and adds registry key to each of those (if I understand your requirements correctly). But you should understand that the responsibility for the output XML is yours. And it will require at least basic knowledge of XSLT transformations language...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.