Using Wix Variables in XSL Transfomration

I am collecting my project files using Heat . but since I want to have shortcuts on the target system, the main executable must be ignored Heat and manually added to the main wxs file . I use the following xsl file to report 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 file name right here, instead I want to set the executable file name as an argument (possibly a wix variable) in the MSbuild file. I would be very grateful if anyone could tell me how this is possible. And what other approaches can I take to solve this problem.

+4
1

, 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>

Heat, , xslt param, .

PS: - . , .

+2

Source: https://habr.com/ru/post/1613661/


All Articles