我正在使用Heat收获我的项目文件。但是由于我要在目标系统上使用快捷方式,因此Heat必须忽略主可执行文件,并手动将其添加到主wxs文件中。我正在使用以下xsl文件来告诉Heat忽略我的可执行文件(Aparati.exe)
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi">
<!-- strip out the exe files from the fragment heat generates. -->
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<xsl:output method="xml" indent="yes" />
<xsl:key name="exe-search" match="wix:Component[contains(wix:File/@Source, 'Aparati.exe')]" use="@Id" />
<xsl:template match="wix:Component[key('exe-search', @Id)]" />
<xsl:template match="wix:ComponentRef[key('exe-search', @Id)]" />
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
问题是我不想在这里直接写文件名,而是想将可执行文件名设置为我的msbuild文件中的一个参数(可能是wix变量)。如果有人能告诉我这是可能的,我将非常感激。我还可以采取什么其他方法来解决此问题。
经过一番研究,我想出了这个解决方案,它从我的 msbuild 文件加载应用程序名称。
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:msbuild="http://schemas.microsoft.com/developer/msbuild/2003">
<!-- strip out the exe files from the fragment heat generates. -->
<xsl:output method="xml" indent="yes" />
<!-- take the app name from msbuild file -->
<xsl:param name="appName" select="document('..\build.proj')//msbuild:AppName/text()"/>
<xsl:param name="exeName" select="concat($appName, '.exe')" />
<!-- copy all the elements -->
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:template>
<!-- except for Component and ComponentRef elements which contain the $exeName -->
<xsl:template match="wix:Component|wix:ComponentRef">
<xsl:choose>
<xsl:when test="contains(wix:File/@Source, $exeName)"></xsl:when>
<xsl:otherwise>
<xsl:copy>
<xsl:apply-templates select="@*|node()" />
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)
我还查看了 Heat 源代码,看看它是否支持 xslt 参数输入,但似乎还不支持该功能。
PS:回到 Heat,我看到了一些非常丑陋的编码。我希望他们考虑重构源代码。
| 归档时间: |
|
| 查看次数: |
636 次 |
| 最近记录: |