Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using WXI files in Visual Studio WiX Project

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">
  <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.

like image 483
Agent_9191 Avatar asked Dec 08 '22 07:12

Agent_9191


1 Answers

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

like image 134
saschabeaumont Avatar answered Mar 16 '23 00:03

saschabeaumont