1
votes

I'm filtering all the .pdb files from my project. On the internet I saw several examples of how to do this with XSLT (because I'm not a XSLT-master I copied some and tried a few). When I have the following XSLT script:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
  <xsl:output method="xml" indent="yes" />
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
  <xsl:template match="wix:ComponentRef[key('service-search', @Id)]" />
</xsl:stylesheet>

But when I execute this with the pre-build event command:

call "C:\Program Files (x86)\WiX Toolset v3.6\bin\heat.exe" dir "..\bin" -t Filter.xslt -sfrag -cg "WebBinaries" -gg -srd -var "var.$(ProjectName).TargetDir" -dr "WebBin" -out "$(SolutionDir)\Deployment\$(ProjectName).binaries.wxs"

I get the following error: Found orphaned Component ...... The reference to the pdb files are correctly removed but a reference to the component that is removed is still there

When I change

<xsl:template match="wix:ComponentRef[key('service-search', @Id)]" />

to

<xsl:template match="wix:ComponentRef[key('service-search', @Id)]" />

I get another error: Unresolved reference to symbol ........ in section fragment

Does anybody know how to solve this problem?

Thanks in advance

1

1 Answers

3
votes

I fixed it with the following xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
  <xsl:output method="xml" indent="yes" />
  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>
  <xsl:key name="service-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
  <xsl:template match="wix:Component[key('service-search', @Id)]" />
  <xsl:template match="wix:ComponentRef[key('service-search', @Id)]" />
</xsl:stylesheet>