XML : WiX remove compont and componentRef of file

I used the vdproj to WiX converter tool as we have several vdproj projects that needed to be updated in a hurry and didn't have time to do them all manually from scratch. In the vdproj projects we excluded the .config files by using the exclude filter *.config, however, this did not translate when the projects were converted to WiX. So I am left with attempting to remove them via the XSLT output.

I have seen several posts on how to do this, however, the ComponentRef piece does not get removed, only the Component. My XSLT is rusty at best and here is what I added to the XSLT that does the transform for the project output.

  .......    <xsl:template match="@*|node()">      <xsl:copy>        <xsl:apply-templates select="@*|node()" />      </xsl:copy>    </xsl:template>    <xsl:key name="config-search" match="wix:Component[contains(wix:File/@Source, '.config')]" use="@Id" />    <xsl:template match="wix:Component[key('config-search', @Id)]" />  <xsl:template match="wix:ComponentRef[key('config-search', @Id)]"/>    .......    

This is what I start with

      <?xml version="1.0" encoding="utf-8"?>  <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">    <Fragment>      <DirectoryRef Id="SearchSync.Binaries">        <Component Id="com_2DDFB814_CA3F_4E1F_8819_2249CB4C1377" Guid="{D07C7189-EFC9-4BA7-8E2F-9287333F2B4C}" Permanent="no" SharedDllRefCount="no" Transitive="no">                  <File Id="_2DDFB814_CA3F_4E1F_8819_2249CB4C1377" DiskId="1" Hidden="no" KeyPath="yes" ReadOnly="no" System="no" Vital="yes" Source="$(var.SearchSync.TargetDir)\SearchSync.exe" />              </Component>        <Component Id="cmpE461B5F48229E9C8A0658DFAEF00FE18" Guid="{9B5BACCF-CCED-4649-AA82-1610C3414650}" Permanent="no" SharedDllRefCount="no" Transitive="no">                  <File Id="fil441B326900F5FE7FF5BEA4BEEACF255C" DiskId="1" Hidden="no" KeyPath="yes" ReadOnly="no" System="no" Vital="yes" Source="$(var.SearchSync.TargetDir)\SearchSync.exe.config" />              </Component>      </DirectoryRef>    </Fragment>    <Fragment>      <ComponentGroup Id="SearchSync.Binaries">  <ComponentRef Id="com_2DDFB814_CA3F_4E1F_8819_2249CB4C1377" />  <ComponentRef Id="cmpE461B5F48229E9C8A0658DFAEF00FE18" />  </ComponentGroup>    </Fragment>  </Wix>    

And this is what I end up with. The Component is removed, but the ComponentRef is not. The ID's of the Component and ComponentRef match. How do I remove the corresponding ComponentRef?

  <?xml version="1.0" encoding="utf-8"?>  <Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">    <Fragment>      <DirectoryRef Id="SearchSync.Binaries">        <Component Id="com_2DDFB814_CA3F_4E1F_8819_2249CB4C1377" Guid="{D07C7189-EFC9-4BA7-8E2F-9287333F2B4C}" Permanent="no" SharedDllRefCount="no" Transitive="no">                  <File Id="_2DDFB814_CA3F_4E1F_8819_2249CB4C1377" DiskId="1" Hidden="no" KeyPath="yes" ReadOnly="no" System="no" Vital="yes" Source="$(var.SearchSync.TargetDir)\SearchSync.exe" />              </Component>        </DirectoryRef>    </Fragment>    <Fragment>      <ComponentGroup Id="SearchSync.Binaries">  <ComponentRef Id="com_2DDFB814_CA3F_4E1F_8819_2249CB4C1377" />  <ComponentRef Id="cmpE461B5F48229E9C8A0658DFAEF00FE18" />  </ComponentGroup>    </Fragment>  </Wix>    

No comments:

Post a Comment