WiX 工具集:.xslt 过滤器没有 return 所需的输出

WiX Toolset: .xslt filter doesn't return desired output

我正在尝试在 WiX 4.0 中使用 heat.exe 收集文件时应用 .xslt 过滤器。例如,我想从结果中排除所有 .pdb 文件。但过滤后的输出与输入 .wxs 文件相同。它似乎不适用我的过滤器。我的过滤器或加热命令有问题吗?我怎样才能至少检查是否应用了过滤器?

我的Filter.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"
  xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">

  <xsl:output method="xml" indent="yes" />

  <xsl:template match="@*|node()">
    <xsl:copy>
      <xsl:apply-templates select="@*|node()"/>
    </xsl:copy>
  </xsl:template>

  <xsl:key name="pdb-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />

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

</xsl:stylesheet>

heat.exe 命令:

"path-to-heat\heat.exe" dir "..\Setup\publish" -t "$(ProjectDir)Filter.xslt"  -dr INSTALLFOLDER -ke -srd -cg MyWebWebComponents -var var.publishDir -gg -scom -sreg -sfrag -srd -o "$(ProjectDir)WebSiteContent.wxs"'

输入WebSiteContent.wxs:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
    <Fragment>
        <DirectoryRef Id="INSTALLFOLDER">
            <Component Id="cmpdgYPmSUffnMp5Cpn.x3uAjrx8LY" Guid="some-guid">
                <File Id="filI8ipbZR_OpcJbpA2FruBKyG8BoI" KeyPath="yes" Source="$(var.publishDir)\Index.html" />
            </Component>
            <Component Id="cmp1pazKwO0_7avtunRUNENlOunN8M" Guid="some-guid">
                <File Id="filyJAF0LmVHHZxVPRdau.BsXwl4nI" KeyPath="yes" Source="$(var.publishDir)\Web.config" />
            </Component>
            <Directory Id="dir_LeTQIBl9a2URA4Zaav7Fa.mwCc" Name="bin">
                <Component Id="cmp5VHxSYpYJIuDX6XWmTs024nLCu0" Guid="some-guid">
                    <File Id="fil_ySBhcWVXR52UqjImhNXHfNFEx0" KeyPath="yes" Source="$(var.publishDir)\bin\WebApplication1.dll" />
                </Component>
                <Component Id="cmp_cTaeilGSxPRLVlsDoZTgBokhS8" Guid="some-guid">
                    <File Id="filZiEpQ2sXyPpzg_SrBAcz1Tbln.A" KeyPath="yes" Source="$(var.publishDir)\bin\WebApplication1.pdb" />
                </Component>
            </Directory>
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="MyWebWebComponents">
            <ComponentRef Id="cmpdgYPmSUffnMp5Cpn.x3uAjrx8LY" />
            <ComponentRef Id="cmp1pazKwO0_7avtunRUNENlOunN8M" />
            <ComponentRef Id="cmp5VHxSYpYJIuDX6XWmTs024nLCu0" />
            <ComponentRef Id="cmp_cTaeilGSxPRLVlsDoZTgBokhS8" />
        </ComponentGroup>
    </Fragment>
</Wix>

我还尝试添加一些自定义操作来编辑 .config 文件:

<util:XmlFile Id="AppConfigConnStr" File="[INSTALLFOLDER]Web.config" Action="setValue" Permanent="yes" Value="[CONNECTION_STRING]" ElementPath="/configuration/connectionStrings/add[\[]@name='MyEntities'[\]]/@connectionString" />

但是也不行

好的,它不起作用的原因是错误的包含命名空间。 Filter.xslt 中的 xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" 应该是 xmlns:wix="http://wixtoolset.org/schemas/v4/wxs"。希望它能帮助人们不要花 12 个小时来查找错误