You could use a bind path (named or unnamed), which I have seen recommended
over the use of preprocessor variables in this forum.

Unnamed bind path:
file source would be:
<File Id=&quot;...&quot; KeyPath=&quot;yes&quot; Source=&quot;\a\b.txt&quot;

and in wixproj or in Properties/Tool Settings/Additional Parameters/Linker
 -b somefolder\somepath\appfolder
or 
 -b &quot;somefolder\somepathwithWhitespace\appfolder\\&quot;

Using a named bind path is similar except that the bindpath is defined as:
-b mybindname=somefolder\somepath\appfolder

then the file source is:
&lt;File Id=&quot;...&quot; KeyPath=&quot;yes&quot;
Source=&quot;!(bindpath.mybindname)\a\b.txt&quot;

It will work with or without the separator between !(bindpath....) and the
rest of the path, but if you do not explicitly author File/@Id, and if the
rest of the path is just a file name, then I would make sure to always
author the separator to avoid the whole string &quot;!(bindpath...&quot;
becoming the File/@Id.

With regard to using heat (or HarvestDirectory) you specify your bindname as
a &quot;PreprocessoVariable&quot; even though it is not a preprocessor
variable (which I found confusing initially).
&lt;PreprocessorVariable>wix.mybindname</PreprocessorVariable>
and then specify a XSLT transform
<Transforms>some.xslt;..\..\Common\Transforms\bindpath.xslt</Transforms>
which replaces the $(wix.mybindname) with !(bindname.mybindname), like this

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
    xmlns:msxsl="urn:schemas-microsoft-com:xslt"
        xmlns:wix="http://schemas.microsoft.com/wix/2006/wi";
        exclude-result-prefixes="msxsl">
  <xsl:output method="xml" indent="yes"/>

  <xsl:template match="@* | node()">
    <xsl:copy>
      <xsl:apply-templates select="@* | node()"/>
    </xsl:copy>
  </xsl:template>
    
    
  <xsl:key name="thumbs.db-search"
match="wix:Component[contains(wix:File/@Source, 'Thumbs.db')]" use="@Id" />
  <xsl:template match="wix:Component[key('thumbs.db-search', @Id)]" />
  <xsl:template match="wix:ComponentRef[key('thumbs.db-search', @Id)]" />

  <xsl:key name="svn-search" match="wix:Component[contains(wix:File/@Source,
'*.svn')]" use="@Id" />
  <xsl:template match="wix:Component[key('svn-search', @Id)]" />
  <xsl:template match="wix:ComponentRef[key('svn-search', @Id)]" />

  
  <xsl:template name="string-replace-all">
    <xsl:param name="text" />
    <xsl:param name="replace" />
    <xsl:param name="by" />
    <xsl:choose>
      <xsl:when test="contains($text, $replace)">
        <xsl:value-of select="substring-before($text,$replace)" />
        <xsl:value-of select="$by" />
        <xsl:call-template name="string-replace-all">
          <xsl:with-param name="text"
select="substring-after($text,$replace)" />
          <xsl:with-param name="replace" select="$replace" />
          <xsl:with-param name="by" select="$by" />
        </xsl:call-template>
      </xsl:when>
      <xsl:otherwise>
        <xsl:value-of select="$text" />
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

  <xsl:template match="@Source['!(wix.']" >

    <xsl:attribute name="Source">

      <xsl:variable name="projectName">
        <xsl:value-of
select="/wix:Wix/wix:Fragment/wix:ComponentGroup/@Id"/>
      </xsl:variable>

      <xsl:call-template name="string-replace-all">
        <xsl:with-param name="text" select="." />
        <xsl:with-param name="replace" select="'!(wix.'" />
        <xsl:with-param name="by" select="'!(bindpath.'" />
      </xsl:call-template>

    </xsl:attribute>

  </xsl:template>

</xsl:stylesheet>

For more reading here are a couple of more links:
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/BindPath-and-supporting-patches-td7598792.html#a7598817

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Automatically-harvest-files-in-VS-2013-td7597592.html#a7597597






--
View this message in context: 
http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/Heat-source-path-tp7599991p7599995.html
Sent from the wix-users mailing list archive at Nabble.com.

------------------------------------------------------------------------------
BPM Camp - Free Virtual Workshop May 6th at 10am PDT/1PM EDT
Develop your own process in accordance with the BPMN 2 standard
Learn Process modeling best practices with Bonita BPM through live exercises
http://www.bonitasoft.com/be-part-of-it/events/bpm-camp-virtual- event?utm_
source=Sourceforge_BPM_Camp_5_6_15&utm_medium=email&utm_campaign=VA_SF
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to