I am working on wix, and i need to install a windows service.
As part of that, i need to set KeyPath="yes"
only on the service executable.
I am using HarvestDirectory
task that produces an output like so:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" Guid="*">
<File Id="fil1F519C40510B9CE08968AFE1141C5124" KeyPath="yes" Source="$(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.dll" />
</Component>
<!-- Many more here -->
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductFiles">
<ComponentRef Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" />
<!-- Many more here -->
</ComponentGroup>
</Fragment>
</Wix>
What i want to do is write an XSLT that will change KeyPath to "no" for all files except when Source = $(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.exe
E.g. sample output would be:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" Guid="*">
<!-- note the 'no' in the KeyPath here -->
<File Id="fil1F519C40510B9CE08968AFE1141C5124" KeyPath="no" Source="$(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.dll" />
</Component>
<Component Id="cmp5BB0346D363B37CAFD72ED8BBAFE3DC3" Guid="*">
<File Id="fil2F519C40510B9CE08968AFE1141C5124" KeyPath="yes" Source="$(var.My.Awesome.Product.TargetDir)\My.Awesome.Product.exe" />
</Component>
<!-- Many more here -->
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductFiles">
<ComponentRef Id="cmp4BB0346D363B37CAFD72ED8BBAFE3DC3" />
<ComponentRef Id="cmp5BB0346D363B37CAFD72ED8BBAFE3DC3" />
<!-- Many more here -->
</ComponentGroup>
</Fragment>
</Wix>
I have got the following XSLT that replaces 'yes' with 'no' on all KeyPath attributes:
<?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:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@KeyPath">
<xsl:attribute name="KeyPath">
<xsl:value-of select="'no'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
I tried manipulating the match in the second template using parent
, ancestor
and simple node with attributes File[@KeyPath='yes']
selectors to no avail.