I am trying to apply .xslt
filter when harvest files using heat.exe in WiX 4.0
. For example I want to exclude all .pdb
files from result. But output after filter is the same as input .wxs
file. It seems like it does not apply my filter. Is it something wrong with my filter or heat command? And how can I at least check if filter was applied?
My Filter.xslt
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
xmlns:util="http://wixtoolset.org/schemas/v4/wxs/util">
<xsl:output method="xml" indent="yes" />
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:key name="pdb-search" match="wix:Component[contains(wix:File/@Source, '.pdb')]" use="@Id" />
<xsl:template match="wix:Component[key('pdb-search', @Id)]" />
<xsl:template match="wix:ComponentRef[key('pdb-search', @Id)]" />
</xsl:stylesheet>
heat.exe
command:
"path-to-heat\heat.exe" dir "..\Setup\publish" -t "$(ProjectDir)Filter.xslt" -dr INSTALLFOLDER -ke -srd -cg MyWebWebComponents -var var.publishDir -gg -scom -sreg -sfrag -srd -o "$(ProjectDir)WebSiteContent.wxs"'
Input WebSiteContent.wxs
:
<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
<Fragment>
<DirectoryRef Id="INSTALLFOLDER">
<Component Id="cmpdgYPmSUffnMp5Cpn.x3uAjrx8LY" Guid="some-guid">
<File Id="filI8ipbZR_OpcJbpA2FruBKyG8BoI" KeyPath="yes" Source="$(var.publishDir)\Index.html" />
</Component>
<Component Id="cmp1pazKwO0_7avtunRUNENlOunN8M" Guid="some-guid">
<File Id="filyJAF0LmVHHZxVPRdau.BsXwl4nI" KeyPath="yes" Source="$(var.publishDir)\Web.config" />
</Component>
<Directory Id="dir_LeTQIBl9a2URA4Zaav7Fa.mwCc" Name="bin">
<Component Id="cmp5VHxSYpYJIuDX6XWmTs024nLCu0" Guid="some-guid">
<File Id="fil_ySBhcWVXR52UqjImhNXHfNFEx0" KeyPath="yes" Source="$(var.publishDir)\bin\WebApplication1.dll" />
</Component>
<Component Id="cmp_cTaeilGSxPRLVlsDoZTgBokhS8" Guid="some-guid">
<File Id="filZiEpQ2sXyPpzg_SrBAcz1Tbln.A" KeyPath="yes" Source="$(var.publishDir)\bin\WebApplication1.pdb" />
</Component>
</Directory>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="MyWebWebComponents">
<ComponentRef Id="cmpdgYPmSUffnMp5Cpn.x3uAjrx8LY" />
<ComponentRef Id="cmp1pazKwO0_7avtunRUNENlOunN8M" />
<ComponentRef Id="cmp5VHxSYpYJIuDX6XWmTs024nLCu0" />
<ComponentRef Id="cmp_cTaeilGSxPRLVlsDoZTgBokhS8" />
</ComponentGroup>
</Fragment>
</Wix>
I also tried to add some custom action for editing .config
file:
<util:XmlFile Id="AppConfigConnStr" File="[INSTALLFOLDER]Web.config" Action="setValue" Permanent="yes" Value="[CONNECTION_STRING]" ElementPath="/configuration/connectionStrings/add[\[]@name='MyEntities'[\]]/@connectionString" />
But it does not work too
Okey, the reason why it did not work was wrong included namespace. Instead of xmlns:wix="http://schemas.microsoft.com/wix/2006/wi"
in Filter.xslt
should be xmlns:wix="http://wixtoolset.org/schemas/v4/wxs"
. Hope it helps someone not to spend 12 hours for searching a mistake