共用方式為


Wix Fragments and how to include them

I really must remember to post more often.

Anyhow, I've been working on a prototype project to convert the custom database used for assembling the Windows SDK in to a Wix based setup.  Thankfully our database was created with an eye on how the MSI database works.  Many of the tables have the same name and same columns as the MSI database.  So converting to Wix wasn't that difficult.  The hard part was figuring out a way to split the Wix files into small manageable chunks and also include the data that is not in the database.

According to the Wix documentation it is suggested that if you have a large project to split each part into its own document with a Fragment element at the top.  So of course this is how I created my files.  Unfortunately I couldn't find any method that would allow me to use a makefile or a list of files for each product.  As far as I can tell you must include all of the compiled files on the command line for the linker.  This, of course, does not work when you have enough files to exceed the length limit for the command line.  The only way I could figure out how to do this is to use the include mechanism that the Wix preprocessor supports.

So I've created a Fragment for each item (Component, ComponentGroup, Feature, etc..) and then use one of the *Ref elements in the element up the chain.  I then close the element I'm working on and add in the include statements.  See the following code sample.  This is one of the files that I've generated.

 <?xml version='1.0'?>
<Include xmlns="https://schemas.microsoft.com/wix/2006/wi">
    <Fragment>
        <ComponentGroup Id="Dexplore_Setup.1750AD3F_40BA_485C_9FFD_27968ACD6BB5">
            <ComponentRef Id="Dexplore_Setup.E29D0C46_40E8_4955_8932_A8642F4416E4" />
        </ComponentGroup>
    </Fragment>
<?include ..\Components\Dexplore_Setup.21585.ddc ?>
</Include>

As you can see the ComponentGroup is referencing the Component element and then outside the Fragment element I include the file that has the definition for the Component.  Using this method you only need to call candle and light on the top level product document. It really makes working with Wix that much easier.  I don't know why this isn't specifically laid out in the Wix documentation, but it really should be in my opinion.

Comments