使用 WiX Toolset 3.10,并尝试创建已使用 WiX Toolset 收获的某些文件的快捷方式heat.exe效用,如:
"%WIX%\bin\heat.exe" dir SourceDir -nologo -platform x64 ^
-ke -gg -g1 -suid -srd -scom -sreg -dr INSTALLDIR ^
-cg ProjFiles -out ProjFiles.wxs
我的问题:
我现在知道我应该使用 XSLT 文件来转换项目文件.wxs (the -t
选项中heat.exe)但是关于如何编写它的 WiX 特定文档是不存在的:有人可以提供一个添加了Shortcut
在桌面上Id
“Prog.exe”?
因为-g1
标志,共享相同基本名称的文件(例如“SourceDir\dirA\file.txt”和“SourceDir\dirZ\file.txt”)将共享相同的Id
(即“文件.txt”);为什么这不是冲突,看看 .MSI 是如何构建并运行正常的?
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 元素。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)