Gilad
Gilad

Reputation: 6595

wix shortcut xsl file


i'm using heat.exe in order to generate the .wxs file for my debug and release directories. usually i'm using this .xsl file in order to generate my shortcuts.

however in my app i need to have a shortcut for the Release version and another one for the Debug version. (since this is being used for development as an SDK)

<?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">

  <xsl:output omit-xml-declaration="yes" indent="yes" encoding="utf-8"/>
  <xsl:strip-space  elements="*"/>


  <xsl:template match="@*|*">
    <xsl:copy>
      <xsl:apply-templates select="@*" />
      <xsl:apply-templates select="*" />
    </xsl:copy>
  </xsl:template>

  <xsl:output method="xml" indent="yes" />

  <xsl:template match="wix:File[@Id='APP.exe']">
    <xsl:copy-of select="."/>
    <Shortcut Id="desktopAPP"
      Advertise="yes"
      Directory="DesktopFolder"
      Name="APP"
      Icon="APP_GUI.ico"
      WorkingDirectory="BIN"
      xmlns="http://schemas.microsoft.com/wix/2006/wi" />

    <Shortcut Id="startmenuAPP"
      Advertise="yes"
      Directory="ProgramMenuFolder"
      Name="APP"
      Icon="APP_GUI.ico"
      WorkingDirectory="BIN"
      xmlns="http://schemas.microsoft.com/wix/2006/wi" />
  </xsl:template>

</xsl:stylesheet>

so basically this is what i'm getting:

   <Component Id="APP.exe" Directory="Debug.amd64" Guid="*">
            <File Id="APP.exe" KeyPath="yes" Source="$(var.BinSourcePath)\Debug.amd64\APP.exe" />
            <Shortcut Id="desktopAPP" Advertise="yes" Directory="DesktopFolder" Name="APP" Icon="APP_GUI.ico" WorkingDirectory="BIN" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
            <Shortcut Id="startmenuAPP" Advertise="yes" Directory="ProgramMenuFolder" Name="APP" Icon="APP_GUI.ico" WorkingDirectory="BIN" xmlns:wix="http://schemas.microsoft.com/wix/2006/wi" />
        </Component>

i want to change my xsl file into creating APP.debug shortcut and APP.Release shortcut i can see the i need to change the xsl to notice if the Component and not the File attribute point to a directory for Release or Debug. and also change the Name accordingly.

can you help me with this xsl?

Upvotes: 2

Views: 934

Answers (1)

Tom Blodget
Tom Blodget

Reputation: 20812

Something like this should work:

<xsl:template match="wix:File[@Id='APP.exe' and contains(../@Directory,'Debug')]">
    <xsl:copy-of select="."/>
    <wix:Shortcut Id="startmenuAPP"
        Advertise="yes"
        Directory="ProgramMenuFolder"
        Name="APP (Debug)"
        Icon="APP_GUI.ico"
        WorkingDirectory="BIN"
    />

Use a similar template for each shortcut you want. I haven't tested it and might have switched which shortcut you want for Debug.

Upvotes: 2

Related Questions