WiX特有的形成記錄,但學習足夠的XSL是一個挑戰。這應該讓你開始。你可能有之前更普遍的或後來者去適應你的名字,熱參數等
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
version="1.0"
xmlns="http://schemas.microsoft.com/wix/2006/wi"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:str="http://xsltsl.org/string"
exclude-result-prefixes="wix str"
>
<xsl:output
encoding="utf-8"
method="xml"
version="1.0"
indent="yes"
/>
<xsl:template match='wix:Component[contains(wix:File/@Source, "SourceDir\Prog.exe")]'>
<!-- assumes there is only one Prog.exe -->
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:comment> added shortcut under Component with File that has Source with Prog.exe </xsl:comment>
<!-- Elsewhere, have an Icon element like: <Icon Id="Prog.exe" SourceFile="$(var.BUILDCACHE)Bin/Prog.exe" /> -->
<Shortcut
Id="ProgExeShortcut"
Name="Prog Application"
Icon="Prog.exe"
Directory="ProgramMenuFolder_ProgVendor"
Advertise="yes">
<xsl:attribute name="WorkingDirectory"><xsl:value-of select="@Directory"/></xsl:attribute>
</Shortcut>
<RemoveFolder
Id="ProgExeShortcut_ProgramMenuFolder_ProgVendor"
Directory="ProgramMenuFolder_ProgVendor"
On="uninstall" />
</xsl:copy>
</xsl:template>
<!-- identity template -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match='/'>
<xsl:comment>*** DO NOT EDIT: Generated by heat.exe; transformed by ProgComponentGroup.xsl</xsl:comment>
<xsl:apply-templates select="@*|node()"/>
</xsl:template>
</xsl:stylesheet>
更具體和更早版本的模板匹配。所以,基礎是複製每個元素,屬性,文本和註釋原樣,除了你想改變的東西。對於那些你想改變的東西,你重構所有的東西 - 在這種情況下,通過複製Component元素的所有東西,然後添加Shortcut和RemoveFolder元素。