WiX, cleaning up the output from dark and tallow

The WiX tools dark and tallow produce .wxs output with Id attributes that are unique, but not necessarily the most human readable. The WiX linker, light doesn't provide line number information for its errors, which means a text search on a string like _6934FA519B917CF946DDC194EB02A1BB when linker errors occur.

With thanks to Bob DuCharme here is a small XSLT script which helps clean up the .wxs output

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wxs=http://schemas.microsoft.com/wix/2003/01/wi >
<
xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
<
xsl:template match="wxs:File">
   <xsl:copy>
      <xsl:attribute name="id">
         
<xsl:choose >
            
<xsl:when test="boolean(@LongName)">
               
<xsl:value-of select="@LongName"/>
            
</xsl:when>
         
<xsl:otherwise>   
            <
xsl:value-of select="@Name"/>
         
</xsl:otherwise>
      
</xsl:choose>
   
</xsl:attribute>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="wxs:File/@Id"></xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</
xsl:stylesheet>

No Comments