Specify a file id with heat in Wix

Viewed 2447

I am harvesting a file with heat and I would really like to give it a decent id rather than the usual "filXXXXXXXX", mostly because I need to refer to it in other parts of the installer. I know that the Id is always the same, on different machines and for different file content apparently so I can stll use it with the confidence that it won't change when builnding, let's say, on a CI server.

Of course it would be much better to have this value a bit more human-friendly. It seems Heat does not have a command-line option to generate file ids (EDIT: apparently there is a -suid option that will stop generating numerical IDs and just use the filename as the ID, anyway that's not feasible in a lot of scenarios), so I am going through the pain of writing an XSLT, but cannot achieve what I want, can anyone help?

This is the Fragment file:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="DBScripts" />
    </Fragment>
    <Fragment>
        <ComponentGroup Id="CSInstallerConfig">
            <Component Id="cmpD6BAFC85C2660BE8744033953284AB03" Directory="DBScripts" Guid="{A39BABF5-2BAC-46EE-AE01-3B47D6C1C321}">
                <File Id="filB31AC19B3A3E65393FF9059147CDAF60" KeyPath="yes" Source="$(var.CONFIG_PATH)\CSInstaller.config" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

And this is the XSLT:

<?xml version="1.0" encoding="utf-8"?>
<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">
    <xsl:output method="xml" indent="yes"/>
    <xsl:template match="@*|*">
        <xsl:copy>
            <xsl:apply-templates select="@*|*" />
        </xsl:copy>
    </xsl:template>
    <xsl:template match="File">
        <xsl:attribute name="Id">
            <xsl:value-of select="123"/>
        </xsl:attribute>
    </xsl:template>
</xsl:stylesheet>

Now, I'm a real noob with XSL so maybe the file above is total nonsense, but anyway what's happening is that the "File" element is copied straight away without the Id being changed.

Any idea?

1 Answers
Related