2
votes

I'm trying to harvest a directory called Release however in my installer i want the files to be installed into "bin".

this is my Pre-Built Event Command line which I have add into my wix3.7 in Visual studio 2012

"%WIX%\bin\heat.exe" dir "$(SolutionDir)\Export\Release" -dr INSTALLFOLDER -cg ExportComponentGroup -var var.sourcePath -ag -sreg -suid -out "$(SolutionDir)\SetupProject\ProjExportDir.wxs"

how can i change the output from this:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="INSTALLFOLDER">
            <Directory Id="dir813D1F0C17C6517DA1B9A933450C5B91" Name="Release" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="ExportComponentGroup">
            <Component Id="cmp6711F65C37F4310E92A3213080231DA6" Directory="dir813D1F0C17C6517DA1B9A933450C5B91" Guid="*">
                <File Id="filABBC16CBAD4348690B2250C408181254" KeyPath="yes" Source="$(var.sourcePath)\3AWrapper.dll" />
            </Component>

into this:

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <DirectoryRef Id="INSTALLFOLDER">
            <Directory Id="bin" Name="bin" />
        </DirectoryRef>
    </Fragment>
    <Fragment>
        <ComponentGroup Id="ExportComponentGroup">
            <Component Id="cmp6711F65C37F4310E92A3213080231DA6" Directory="bin" Guid="*">
                <File Id="filABBC16CBAD4348690B2250C408181254" KeyPath="yes" Source="$(var.sourcePath)\3AWrapper.dll" />
            </Component>

I have tried using -directoryid flag however this isn't working.

2

2 Answers

3
votes

There are a couple ways to do this.

1) XSL transform Heat will run a transform for you before writing the output file. You just have to supply the .xsl file. This a general method for anything about the heat output that you need to change. If another method worked, I would do that instead.

2) -srd switch Manually author the bin Directory in another wxs file and get heat to reference it as the parent of the harvested items, without generating another Directory for the root folder Release. heat dir "$(SolutionDir)\Export\Release" -dr bin -srd ...

Example in Product.wxs:

<!-- Under Wix/Product -->
<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="SetupProject1">
        <Directory Id="bin" Name="bin" />
      </Directory>
    </Directory>
  </Directory>
</Fragment>
2
votes

In case you want to use XSL transform then you can use the following:

<xsl:stylesheet version="2.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"/>
 <xsl:template match="node()|@*">
  <xsl:copy>
   <xsl:apply-templates select="node()|@*"/>
  </xsl:copy>
 </xsl:template>  

 <xsl:template match="wix:Directory[@Name='Release']/@Id">
  <xsl:attribute name="Id">BIN</xsl:attribute>
 </xsl:template>

</xsl:stylesheet>