Search code examples
wixwix3.9wixlib

Dealing with orphaned components while linking wixlib


I am tasked to build 2 installers based on the same wixlib supplied by 3rd party. Full installer includes all Components, Lite only the core stuff. I assume the wixlib has the following structure:

<Fragment>
  <ComponentGroup Id="CoreStuff">
    <!-- List of components for this bit, roughly 5MB -->
  </ComponentGroup>
</Fragment>
<Fragment>
  <ComponentGroup Id="ExtraStuff">
    <!-- List of components for this bit, roughly 45MB -->
    <ComponentRef Id="BigFile1"/>
  </ComponentGroup>
  <Component Id="BigFile1">
    <File Id="BigFile1_bin" Name="BigFile1.bin"/>
  </Component>
</Fragment>

The installer is build in msbuild. The components are included in to the project the following way:

<Feature Id="ThirdPartyStuff">
  <ComponentGroupRef Id="CoreStuff"/>
  <?if $(var.Configuration) = "Full"?>
  <ComponentGroupRef Id="ExtraStuff"/>
  <?endif?>
</Feature>

In the end, as expected, I get LGHT0267 error:

error LGHT0267: Found orphaned Component 'BigFile1'. If this is a Product, every Component must have at least one parent Feature. To include a Component in a Module, you must include it directly as a Component element of the Module element or indirectly via ComponentRef, ComponentGroup, or ComponentGroupRef elements.

Have anyone come up with workaround on how to selectively use components provided in wixlib? I could include ExtraStuff as separate Feature for user, but the goal here is to shrink the installer. I could ask politely ThirdParty to provide two separate wixlib's, but I'd like to avoid it.


Solution

  • After a struggle I have got the workaround, nasty workaround:

    1. Create dummy wixproject and include wixlib as you would normally do.
    2. Add dummy project as your dependency for final project
    3. In post-build event of dummy project set powershell script to run, which will:
      • De-compile dummy.msi with binaries output (switch -x) using dark.exe
      • Craft new.wxs file based on dummy.wxs with inclusion of tags to make the components conditional
    4. Include new.wxs in the final project