Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Customize KeyPath item when using wix heat.exe to harvest multiple files

Tags:

wix

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.

like image 674
Dafan Dong Avatar asked Feb 10 '11 18:02

Dafan Dong


2 Answers

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.

like image 21
Yan Sklyarenko Avatar answered Oct 19 '22 18:10

Yan Sklyarenko


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

like image 125
Ujjwal Singh Avatar answered Oct 19 '22 18:10

Ujjwal Singh