views:

1666

answers:

2

I've come across several sources stating to split up a WiX installation file into the separate parts (variables, components, etc.) using include files (.wxi). Makes perfect sense to me, so I took the <components> nodes out of the .wxs file and put them in a separate file, but when I attempt to compile the project in Visual Studio 2008 I get an error for each <ComponentRef> stating it's an "Unresolved reference to symbol '...' in section 'Product:{...}'".

I've tried using the <?include "Filename"?> tag in my Product.wxs file, but that seems to break the schema validation. If that's the way to include it, _**where**_ does it need to go?

The files I have are the following.

Product.wxs

<?xml version="1.0" encoding="utf-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
  <Product ...>
    <Package .../>
    <Media .../>
    <Directory Id="TARGETDIR" Name="SourceDir">
    </Directory>
    <Feature Id="MainProgram" Level="1">
      <ComponentRef Id="ProductComponent" />
      <Feature Id="ContextMenu" Level="2">
        <ComponentRef Id="ContextMenuComponent" />
      </Feature>
    </Feature>
  </Product>
</Wix>

Components.wxi

<?xml version="1.0" encoding="utf-8"?>
<Include>
  <Fragment>
    <Component Id="ProductComponent" ...>
      <File .../>
    </Component>
    <Component Id="ContextMenuComponent" ...>
      <RegistryKey .../>
    </Component>
  </Fragment>
</Include>

How do I get it to build in Visual Studio? Scripting the build seems simpler, but not an issue of mine just yet.

+2  A: 

Try using the WXS extension rather than WXI. I have broken mine up and used WXS as the extension, and it just worked. All WXS files in the project are passed into the wix compiler by the wixproj.

David McEwing
@David McEwing yes, all off the .wxs files are passed to candle (the compiler that creates a bunch of .wixobjs) *then* all of the .wixobjs are passed to light (the linker that "links" .wixobjs and .wixlibs) to filter out the stuff you don't reference and create the .MSI/.MSM.
Rob Mensching
+6  A: 

Include files should be thought of as header files, you really only want to use them to declare common variables, etc that you need to share between multiple .wxs files.

My project uses ~10 .wxs files and a single .wxi that I define the product code, upgrade code, etc in.

For a better idea of what I'm talking about check out the SO questions Wix Tricks & Best Practices and WiX Includes vs. Fragments as well, as always, the documentation in Wix.chm

sascha
@sascha has the right suggestion here. You don't need an include at all in your system above. That's the power of candle/light.
Rob Mensching