Wix安装程序:如何使用xslt向.wxs文件中的元素添加属性节点



我试图将属性DiskId="2"添加到我的。wxs文档中的每个<File/>节点。

这是我当前的。wxs文档。

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="gamefolder">
<Directory Id="dirF711F97310B8A07830DC0D0162651C53" Name="Binaries">
<Directory Id="dir6680B101073A3BBEE0196B38B72D6ACF" Name="Win64">
<Component Id="cmpE50AA454EF4441084B9D3A91EBCDEB66" Guid="*">
<File Id="fil64DFAE28B352BA139C0419EA1DCA51AF" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64game.exe" />
</Component>
<Component Id="cmp1E519BFC50337D4D04783020429A732A" Guid="*">
<File Id="filB5DEFA58FD85ED12A275C6E38E86E1B5" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64game.pdb" />
</Component>
<Component Id="cmp73737DFB25572225F51408CA794B189B" Guid="*">
<File Id="fil9A8FF16C3162A983C3BE9966F4D729BE" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64mydll.dll" />
</Component>
<Component Id="cmp27FB4DBD5C6B91D53682E31F9F252271" Guid="*">
<File Id="fil8F6BD7CF55FB9B153E3CBF0D64EEA1D6" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64mydll2.dll" />
</Component>
</Directory>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="GeneratedGameFiles1">
<ComponentRef Id="cmpE50AA454EF4441084B9D3A91EBCDEB66" />
<ComponentRef Id="cmp1E519BFC50337D4D04783020429A732A" />
<ComponentRef Id="cmp73737DFB25572225F51408CA794B189B" />
<ComponentRef Id="cmp27FB4DBD5C6B91D53682E31F9F252271" />
</ComponentGroup>
</Fragment>
</Wix>

运行下面的xslt后,它没有改变任何东西。

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="msxsl"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
<xsl:output method="xml" indent="yes" />
<xsl:strip-space elements="*"/>
<xsl:template match='Component/File'>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="DiskId">
<xsl:text>2</xsl:text>
</xsl:attribute>
</xsl:copy>
</xsl:template>

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

</xsl:stylesheet>

这就是我想要得到的结果。

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="gamefolder">
<Directory Id="dirF711F97310B8A07830DC0D0162651C53" Name="Binaries">
<Directory Id="dir6680B101073A3BBEE0196B38B72D6ACF" Name="Win64">
<Component Id="cmpE50AA454EF4441084B9D3A91EBCDEB66" Guid="*">
<File DiskId="2" Id="fil64DFAE28B352BA139C0419EA1DCA51AF" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64game.exe" />
</Component>
<Component Id="cmp1E519BFC50337D4D04783020429A732A" Guid="*">
<File DiskId="2" Id="filB5DEFA58FD85ED12A275C6E38E86E1B5" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64game.pdb" />
</Component>
<Component Id="cmp73737DFB25572225F51408CA794B189B" Guid="*">
<File DiskId="2" Id="fil9A8FF16C3162A983C3BE9966F4D729BE" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64mydll.dll" />
</Component>
<Component Id="cmp27FB4DBD5C6B91D53682E31F9F252271" Guid="*">
<File DiskId="2" Id="fil8F6BD7CF55FB9B153E3CBF0D64EEA1D6" KeyPath="yes" Source="$(var.HarvestPath1)BinariesWin64mydll2.dll" />
</Component>
</Directory>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="GeneratedGameFiles1">
<ComponentRef Id="cmpE50AA454EF4441084B9D3A91EBCDEB66" />
<ComponentRef Id="cmp1E519BFC50337D4D04783020429A732A" />
<ComponentRef Id="cmp73737DFB25572225F51408CA794B189B" />
<ComponentRef Id="cmp27FB4DBD5C6B91D53682E31F9F252271" />
</ComponentGroup>
</Fragment>
</Wix>

我在这里做错了什么?

变化:

<xsl:template match='Component/File'>

:

<xsl:template match='wix:Component/wix:File'>