0

I am trying to add the attribute DiskId="2" to each <File/> node in my .wxs document.

Here is my current .wxs document.

<?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)\Binaries\Win64\game.exe" />
                    </Component>
                    <Component Id="cmp1E519BFC50337D4D04783020429A732A" Guid="*">
                        <File Id="filB5DEFA58FD85ED12A275C6E38E86E1B5" KeyPath="yes" Source="$(var.HarvestPath1)\Binaries\Win64\game.pdb" />
                    </Component>
                    <Component Id="cmp73737DFB25572225F51408CA794B189B" Guid="*">
                        <File Id="fil9A8FF16C3162A983C3BE9966F4D729BE" KeyPath="yes" Source="$(var.HarvestPath1)\Binaries\Win64\mydll.dll" />
                    </Component>
                    <Component Id="cmp27FB4DBD5C6B91D53682E31F9F252271" Guid="*">
                        <File Id="fil8F6BD7CF55FB9B153E3CBF0D64EEA1D6" KeyPath="yes" Source="$(var.HarvestPath1)\Binaries\Win64\mydll2.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>

After running the following xslt it, It doesn't change anything at all.

<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>

This is the result I'm trying to get.

<?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)\Binaries\Win64\game.exe" />
                    </Component>
                    <Component Id="cmp1E519BFC50337D4D04783020429A732A" Guid="*">
                        <File DiskId="2" Id="filB5DEFA58FD85ED12A275C6E38E86E1B5" KeyPath="yes" Source="$(var.HarvestPath1)\Binaries\Win64\game.pdb" />
                    </Component>
                    <Component Id="cmp73737DFB25572225F51408CA794B189B" Guid="*">
                        <File DiskId="2" Id="fil9A8FF16C3162A983C3BE9966F4D729BE" KeyPath="yes" Source="$(var.HarvestPath1)\Binaries\Win64\mydll.dll" />
                    </Component>
                    <Component Id="cmp27FB4DBD5C6B91D53682E31F9F252271" Guid="*">
                        <File DiskId="2" Id="fil8F6BD7CF55FB9B153E3CBF0D64EEA1D6" KeyPath="yes" Source="$(var.HarvestPath1)\Binaries\Win64\mydll2.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>

What could I be doing wrong here?

1 Answers1

1

Change:

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

to:

<xsl:template match='wix:Component/wix:File'>
michael.hor257k
  • 113,275
  • 6
  • 33
  • 51