[wix-users] Transfer to Exclude Directories{
James Buchan
James.Buchan at servelec-synergy.com
Thu Oct 20 01:44:45 PDT 2016
I remember when this gave me headaches.
It's because your search returns the directory ID (e.g. dir9325DAD3A79384E16846E07E932E4248) and it this ID you are then looking for in the ComponentRef list (which wont exist). The trick, is to look at the child nodes (Component) of the directory and grab their ID's as it is these you want to search for and remove.
Here's a copy of my transform template file that I always start from. It will remove both '.pdb' files and a folder called 'customisations' and all components (and references to it) contained within.
Note the use of "descendant::wix:Component/@Id" against the folder search, this is what does the magic.
<?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 method="xml" indent="yes" />
<!-- Set up keys for ignoring various file types -->
<xsl:key name="pdb_search" match="wix:Component[(contains(wix:File/@Source, '.pdb'))]" use="@Id"/>
<xsl:key name="Folder_customisations_search" match="wix:Directory[@Name = 'customisations']" use="descendant::wix:Component/@Id" />
<!-- Match and remove .pdb files -->
<xsl:template match="wix:Component[(contains(wix:File/@Source, '.pdb'))]"/>
<xsl:template match="wix:ComponentRef[key('pdb_search', @Id)]" />
<!--Match and remove customisations folder-->
<xsl:template match="wix:Directory[@Name='customisations']" />
<xsl:template match="wix:ComponentRef[key('Folder_customisations_search', @Id)]" />
<!-- Copy all attributes and elements to the output. -->
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="*" />
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Instead of 'descendant', you could always use 'ancestor' that would look a little something like this.
<xsl:key name=" older_customisations_search" match="wix:Component[ancestor::wix:Directory/@Name = ' customisations]" use="@Id"/>
<xsl:template match="wix:ComponentRef[key('Folder_customisations_search', @Id)]"/>
(Just replace the similar lines in the example above)
Hope that helps,
James
-----Original Message-----
From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf Of Steven Packer
Sent: 19 October 2016 16:47
To: wix-users at lists.wixtoolset.org
Subject: [wix-users] Transfer to Exclude Directories{
I am trying to Harvest a directory and exclude some of the subfolders in this directory. I found an example of a transform to help with this. It works well except that it leaves all of the ComponentRefs for all files, even those in the directories that were excluded. I have tried to change the transfer to exclude the ComponentRefs but have been unsuccessful. I have very limited experience with WiX and transforms and so I am relying on the superior knowledge and intellect of the WiX users group.
This is what my transform looks like. The last section is my attempt to exclude the ComponentRefs. Any help is greatly appreciated.
<?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">
<!-- Copy all attributes and elements to the output. -->
<xsl:template match="@*|*">
<xsl:copy>
<xsl:apply-templates select="@*" />
<xsl:apply-templates select="*" />
</xsl:copy>
</xsl:template>
<xsl:output method="xml" indent="yes" />
<!-- Create searches for the directories to remove. -->
<xsl:key name="plugins-search" match="wix:Directory[@Name = 'Plugins']"
use="@Id" />
<xsl:key name="tellercapture-search" match="wix:Directory[@Name = 'TellerCapture']" use="@Id" />
<xsl:key name="help-search" match="wix:Directory[@Name = 'Help']"
use="@Id" />
<!-- Remove directories. -->
<xsl:template match="wix:Directory[@Name='Plugins']" />
<xsl:template match="wix:Directory[@Name='TellerCapture']" />
<xsl:template match="wix:Directory[@Name='Help']" />
<!-- Remove Components referencing those directories. -->
<xsl:template match="wix:Component[key('plugins-search', @Directory)]" />
<xsl:template match="wix:Component[key('tellercapture-search',
@Directory)]" />
<xsl:template match="wix:Component[key('help-search', @Directory)]" />
<!-- Remove DirectoryRefs (and their parent Fragments) referencing those directories. -->
<xsl:template match="wix:Fragment[wix:DirectoryRef[key('plugins-search',
@Id)]]" />
<xsl:template
match="wix:Fragment[wix:DirectoryRef[key('tellercapture-search', @Id)]]" />
<xsl:template match="wix:Fragment[wix:DirectoryRef[key('help-search',
@Id)]]" />
<!-- Remove ComponentRef referencing those Components. -->
<xsl:template
match="wix:ComponentGroup[wix:ComponentRef[key('plugins-search', @Id)]]" />
<xsl:template
match="wix:ComponentGroup[wix:ComponentRef[key('tellercapture-search',
@Id)]]" />
<xsl:template
match="wix:ComponentGroup[wix:ComponentRef[key('help-search', @Id)]]" />
</xsl:stylesheet>
I also tried this to exclude the ComponentRefs. Still no success.
<xsl:template match="wix:Fragment[wix:ComponentRef[key('plugins-search',
@Id)]]" />
<xsl:template
match="wix:Fragment[wix:ComponentRef[key('tellercapture-search', @Id)]]" />
<xsl:template match="wix:Fragment[wix:ComponentRef[key('help-search',
@Id)]]" />
If there is documentation on how to create transforms I would like to know where to find it. Most of what I have done is guess work because this is very difficult for me to understand.
Thanks,
Steven Packer
This email and any files transmitted with it are confidential. If you have received this email in error please delete it immediately. Note that any views or opinions presented in this email are solely those of the author and do not necessarily represent those of DHI. Finally, this email and attachments have been scanned for viruses; however, DHI Computing Service accepts no liability for any damage caused by any virus transmitted by this email.
____________________________________________________________________
WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
More information about the wix-users
mailing list