Using XSLT to add new node item to WiX source code.
Original WiX Code:
<Fragment> <DirectoryrefId= "TARGETDIR"> <ComponentGuid="*"Id= "Test.txt"> <FileKeyPath= "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> <DirectoryrefId= "TARGETDIR"> <ComponentGuid="*"Id= "Test.txt"> <FileKeyPath= "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 does the work:
<Xsl:stylesheetversion= "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:outputMethod= "xml"Indent= "Yes"/> <xsl:templateMatch= "@* | Node ()"> <xsl:copy> <xsl:apply-templatesSelect= "@* | Node ()"/> </xsl:copy> </xsl:template> <xsl:templateMatch= "Wi:file"> <xsl:copy> <xsl:variablename= "Leadingspace"Select= "Preceding-sibling::text () [1]" /> <xsl:apply-templatesSelect="@*"/> <!--Add linebreak and indentation, as requested in the comments - <xsl:value-ofSelect= "concat ($leadingSpace, ')" /> <CopyFilexmlns= "Http://schemas.microsoft.com/wix/2006/wi"Id= "Test.txt"Destinationproperty= "Binfolder"Destinationname= "Test.txt"/> <!--Linebreak and Indentation - <xsl:value-ofSelect= "$leadingSpace"/> </xsl:copy> </xsl:template></Xsl:stylesheet>
WiX XSLT for adding node