I'm harvesting my project files using Heat. but since I want to have shortcuts on the target system the main executable must be ignored by Heat and added manually in the main wxs file. I'm using the following xsl file to tell heat to ignore my executable file (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>
The problem is that I don't want to write the filename directly here, instead I want to set the executable filename as an argument (maybe a wix variable) in my msbuild file. I would be very thankful if anyone could tell me how it is possible. And what other approaches can I take to solve this problem.
After some research, I came up with this solution which loads the Application Name from my msbuild file.
<?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>
I also took a look at the Heat source code to see if it supports xslt param input but it doesn't seem to support the feature yet.
PS: Back there on Heat I saw some real ugly coding. I hope they consider refactoring the source.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With