0

Is there a way to direct HeatDirectory task in my wixproj to harvest only files at the root level and not to dive into any sub-directories? For sure I can handle it running XSL transform on the output file, but I would prefer a cleaner way. If there is no way then I'd appreciate if anyone has a clean example of XSL transform snippet to handle it (will save me time at least). Thanks a lot :)

Tiger Galo
  • 289
  • 4
  • 15
  • I wrote the XSLT snippet to remove all subfolders and files inside, which also removes all associated ComponentRef tags under ComponentGroup, however, I hope there is a cleaner way without xslt, if not will later post this as an alternative answer: – Tiger Galo Mar 28 '22 at 16:43

2 Answers2

1

XSLT seems to be the most suitable way. A couple of other solutions are mentioned here: How to exclude files in Wix toolset, like making a copy of files to harvest or using external opensource app.

Also Wix has commercial expansion pack with more powerful replacement of heat.exe, which can exclude files and folder, use masks: https://www.firegiant.com/wix/wep-documentation/harvesting/harvestfolder/

Kirumata
  • 165
  • 1
  • 9
  • Yea, I used in the past Firegiant's expansion tool, it's truly a good one. It's just here I don't have that tool yet, unless we purchase it in the future. So for now what I figured out is to stick to the xslt transforms. Thanks for the answer @Kirumata. – Tiger Galo Mar 29 '22 at 16:03
0

Since it looks like there is no integrated way to handle it through the HeatDirectory task input parameters, then I will post the XSLT snipped I wrote which does that work for me. Whoever uses it needs to modify as per need accordingly:

<xsl:key name="SubDirComponentKeys" match="/wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Directory/wix:Directory//wix:Component" use="@Id" />
<xsl:template match="/wix:Wix/wix:Fragment/wix:DirectoryRef/wix:Directory/wix:Directory" />
<xsl:template match="//wix:ComponentRef[contains(key('SubDirComponentKeys',@Id)/wix:File/@Source, '\')]" />
Tiger Galo
  • 289
  • 4
  • 15