Is it possible to include only certain file Extensions when using an xslt file to transform heat harvesting components using wix? I know I can exclude file extensions with the following:
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" /> <!--.pdb-->
but is it possible to include several file types and exclude everything else (for example: .exe, .dll, .xml)?
Thank you!
Sure. Inside the condition, you can use full expressions, like:
   contains(wix:File/@Source, '.pdb') 
or contains(wix:File/@Source, '.exe') 
or contains(wix:File/@Source, '.dll') 
or contains(wix:File/@Source, '.xml')
If it's just an handful, that should be maintainable. To aid readability, you can put newlines inside the match attribute value (or any attribute in general).
I would use it like this. Notice the poor man's ends-with trick.
The template matches unwanted Components and replaces them with nothing.
<xsl:stylesheet 
    version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    xmlns:wi="http://schemas.microsoft.com/wix/2006/wi" 
    xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <xsl:template match="wi:Component[not(
        contains(concat(wi:File/@Source,'|'), '.exe|') or
        contains(concat(wi:File/@Source,'|'), '.config|'))]">
     </xsl:template>
     <xsl:template match="node()|@*">
       <xsl:copy>
       <xsl:apply-templates select="@*"/>
       <xsl:apply-templates/>
       </xsl:copy>
     </xsl:template>
 </xsl:stylesheet>
Here's a heat command that it works with:
heat dir "%wix%\bin" -cg CompGroup -ag -t byext.xsl -o test.wxs
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With