WiX 工具集:.xslt 过滤器未返回所需的输出

问题描述 投票:0回答:1

我正在尝试在

.xslt
中使用 heat.exe 收获文件时应用
WiX 4.0
过滤器。例如,我想从结果中排除所有
.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" />

但是也不起作用

xslt wix heat
1个回答
9
投票

好吧,它不起作用的原因是包含的命名空间错误。

xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
中的
Filter.xslt
应该是
xmlns:wix="http://wixtoolset.org/schemas/v4/wxs"
。希望它可以帮助人们不要花 12 个小时来寻找错误

© www.soinside.com 2019 - 2024. All rights reserved.