标签:
Using xslt to add new node item to wix source code.
Original wix code:
<Fragment> <DirectoryRef Id="TARGETDIR"> <Component Guid="*" Id="Test.txt"> <File KeyPath="yes" Source="$(var.TestFolder)\Test.txt" Id="Test.txt" /> </Component> </DirectoryRef> </Fragment>
Add <CopyFile /> node inside <File> node, the expected wix code would be:
<Fragment> <DirectoryRef Id="TARGETDIR"> <Component Guid="*" Id="Test.txt"> <File KeyPath="yes" Source="$(var.TestFolder)\Test.txt" Id="Test.txt" > <CopyFile Id ="Test.txt" DestinationProperty="BinFolder" DestinationName="test.txt" /> </File> </Component> </DirectoryRef> </Fragment>
Pass this xslt to heat.exe with -t option should do the work:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:wi="http://schemas.microsoft.com/wix/2006/wi" exclude-result-prefixes="wi"> <xsl:output method="xml" indent="yes"/> <xsl:template match="@* | node()"> <xsl:copy> <xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> <xsl:template match="wi:File"> <xsl:copy> <xsl:variable name="leadingSpace" select="preceding-sibling::text()[1]" /> <xsl:apply-templates select="@*"/> <!-- Add linebreak and indentation, as requested in the comments --> <xsl:value-of select="concat($leadingSpace, ‘ ‘)" /> <CopyFile xmlns="http://schemas.microsoft.com/wix/2006/wi" Id="Test.txt" DestinationProperty="BinFolder" DestinationName="test.txt"/> <!-- Linebreak and indentation --> <xsl:value-of select="$leadingSpace"/> </xsl:copy> </xsl:template> </xsl:stylesheet>
标签:
原文地址:http://www.cnblogs.com/cindy-hu-23/p/5036002.html