Derek Cicerone Installing...

WiX, Setup, and trying to make it all easy, not just easier

Monday, January 09, 2006

Candle (part 1)

The core of the WiX toolset primarily consists of a compiler and a linker. The compiler is called candle and the linker is called light (here's an explanation of how these names came about). The functionality provided in each of these tools seems to be a source of constant debate by many users of WiX. I've even been confused about whether a certain operation was performed in the compiler or linker from time-to-time. For this post, I'd like to talk about candle. Parsing The guts of candle are basically implemented in two classes: preprocessor.cs (the preprocessor) and compiler.cs (the compiler). Let's leave a discussion of preprocessor.cs for another time. The class Microsoft.Tools.WindowsInstallerXml.Compiler in compiler.cs is nothing more than a simple recursive-decent parser. Although the formal definition seems to make this seem complicated, it really isn't. An example will probably be the easiest way to illustrate how simple the parsing code is. Here's the contents of a simple WiX source file (let's call it example.wxs):




The compiler will begin parsing this file by looking at the element first. This is done by calling ParseWixElement. Inside the method ParseWixElement (which can be found in compiler.cs), there is a foreach loop for processing each of the child elements under a Wix element. In fact, here's a simplied version of what that code looks like: ///
/// Parses a Wix element.
///
/// Element to parse.
private void ParseWixElement(XmlNode node)
{
foreach (XmlNode child in node.ChildNodes)
{
if (XmlNodeType.Element == child.NodeType)
{
switch (child.LocalName)
{
case "Fragment":
this.ParseFragmentElement(child);
break;
case "Product":
this.ParseProductElement(child);
break;
default:
this.core.UnexpectedElement(node, child);
break;
}
}
}
} Since the first child element of the element is a element, the compiler will then call ParseFragmentElement. This method would then call ParsePropertyElement. There is a Parse*Element method for each of the elements supported by WiX in its source files. Each element roughly corresponds to a particular table in an MSI file. So, in the example above, we'd be creating a single row in the Property table by writing a element. To be continued...

2 Comments:

At Tuesday, May 09, 2006 9:37:00 AM, Blogger Gope said...

Hello,
couldn't find your email, so I try it this way. Do you have information on an API-Documentation for the WiX-DLLs?

Thanks in advance
Gerritp@newtelligence.com

 
At Tuesday, May 09, 2006 9:48:00 AM, Blogger Derek Cicerone said...

Hi gope - there is lots of information about how to use wix in wix.chm (which is distributed in all wix releases). Also, if there is a question not answered by that documentation, please feel free to send mail to wix-users@lists.sourceforge.net.

 

Post a Comment

<< Home