summaryrefslogtreecommitdiffstats
path: root/src/etc/installer/msi/squash-components.xsl
diff options
context:
space:
mode:
Diffstat (limited to 'src/etc/installer/msi/squash-components.xsl')
-rw-r--r--src/etc/installer/msi/squash-components.xsl34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/etc/installer/msi/squash-components.xsl b/src/etc/installer/msi/squash-components.xsl
new file mode 100644
index 000000000..17b4e0388
--- /dev/null
+++ b/src/etc/installer/msi/squash-components.xsl
@@ -0,0 +1,34 @@
+<?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:copy>
+ </xsl:template>
+ <xsl:output method="xml" indent="yes" />
+
+ <!-- Move all files in directory into first component in that directory. -->
+ <xsl:template match="wix:Component[1]">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|*"/>
+ <xsl:for-each select="../wix:Component[preceding-sibling::*]/wix:File">
+ <xsl:copy>
+ <!-- Component can only have one KeyPath -->
+ <xsl:apply-templates select="@*[not(name()='KeyPath')]|*"/>
+ </xsl:copy>
+ </xsl:for-each>
+ </xsl:copy>
+ </xsl:template>
+
+ <!-- Now the rest of components are empty, find them. -->
+ <xsl:key name="empty-cmp-ids" match="wix:Component[preceding-sibling::*]" use="@Id" />
+
+ <!-- And remove. -->
+ <xsl:template match="wix:Component[preceding-sibling::*]" />
+
+ <!-- Also remove componentsrefs referencing empty components. -->
+ <xsl:template match="wix:ComponentRef[key('empty-cmp-ids', @Id)]" />
+</xsl:stylesheet>