[wix-users] Referencing a library project artifact (wixlib) from a setup project (MSI)

Edwin Castro egcastr at gmail.com
Fri Dec 1 12:56:32 PST 2017


Yes, <Product> has to directly or indirectly reference everything it needs.
It is possible the wixlib is being referenced directly within <Product> in
the larger project but perhaps it is referenced in a <Fragment> that is
directly or indirectly referenced in <Product>. That does make it difficult
to figure out how the wixlib is used.

I'm going to suggest an approach that is time-consuming but it truly is the
best way to figure out how the wixlib is used. At the very least, it should
help you understand how referencing works in WiX.

Quick note: I haven't checked the lengths for my ids below so they are
likely too long!

First, you need to identify the elements that could be referenced. Some
elements have Ref elements which explicitly reference the "base" element.
The easiest example is probably <Directory> and <DirectoryRef>. You can
define a <Directory> structure in one <Fragment> and reference it in
another:

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir"/>
</Fragment>

<Fragment>
    <DirectoryRef Id="TARGETDIR">
        <Directory Id="CommonAppDataFolder">
            <Directory Id="CommonAppDataCompanyFolder" Name="My Company">
                <Directory Id="CommonAppDataApplicationFolder" Name="My
Application"/>
            </Directory>
        </Directory>
    </DirectoryRef>
</Fragment>

<Fragment>
    <DirectoryRef Id="TARGETDIR">
        <Directory Id="ProgramFilesFolder">
            <Directory Id="ProgramFilesCompanyFolder" Name="My Company">
                <Directory Id="ProgramFilesApplicationFolder" Name="My
Application"/>
            </Directory>
        </Directory>
    </DirectoryRef>
</Fragment>

In the example above I define TARGETDIR in one fragment and reference it in
the other two fragments. These three fragments could be in one .wxs file or
they could be in different .wxs files. The files that contain the fragments
don't really matter.

Later we could reference the ProgramFilesApplicationFolder directory in a
different fragment to define the components we're going to install:

<Fragment>
    <DirectoryRef ID="ProgramFilesApplicationFolder">
        <Directory Id="ApplicationBinFolder" Name="bin"/>
    </DirectoryRef>
</Fragment>

<Fragment>
    <ComponentGroup Id="ApplicationBinaries"
Directory="ApplicationBinFolder">
        <Component>
            <File Source="application.exe"/>
        </Component>
        <Component>
            <File Source="helper.exe"/>
        </Component>
    </ComponentGroup>
</Fragment>

First, we reference ProgramFilesApplicationFolder so we can specify that we
need a bin directory there.

Second, we reference ApplicationBinFolder in yet another fragment so that
we can install components in that directory. This reference demonstrates
another style of reference, through an attribute. In this case, we specify
the directory in the <ComponentGroup> element which causes all components
in that group to use the group directory by default if the component
doesn't define its own directory. We could have specified the directory on
each component but that can get tedious and repetitive:

<Fragment>
    <ComponentGroup Id="ApplicationBinaries">
        <Component Directory="ApplicationBinFolder">
            <File Source="application.exe"/>
        </Component>
        <Component Directory="ApplicationBinFolder">
            <File Source="helper.exe"/>
        </Component>
    </ComponentGroup>
</Fragment>

Note there also is a <ComponentGroupRef> so we could reference
ApplicationBinaries in a different fragment. Perhaps one that defines a
<Feature> or defines a "larger" component group that contains
ApplicationBinaries.

To figure out references is to look for the Ref elements like DirectoryRef
and ComponentGroupRef in the larger project and try to match those ids with
ids defined in the wixlib. You also need to be aware of which attributes
are references like Directory in ComponentGroup and Component. In both
cases, the ids you care about are the ones defined in the wixlib and used
in the larger project.

--
Edwin G. Castro


On Fri, Dec 1, 2017 at 9:36 AM, Jace Malloy <jace81657 at gmail.com> wrote:

> Thanks for the reply, Edwin.
>
> Yes, I thought of looking at the setup project in the "larger" project and
> it was overwhelming. There were so many files. I searched for specific
> components, but nothing jumped out at me. I couldn't find the entry
> point...I assume it to be the Product.wxs file.
>
> I then thought I could (initially), just cut the Feature element (and all
> the children of course) from the Library.wxs file, and paste it into the
> main setup project somewhere. I'm not sure I know what I'm doing, but
> that's what I'm going to try now. I've been reading through the WiX doc,
> and spending time on the FireGiant site.
>
>
> On Fri, Dec 1, 2017 at 12:18 PM, Edwin Castro <egcastr at gmail.com> wrote:
>
>> The details matter... in general you need to add an element reference of
>> some kind into your setup project (that is in addition to the project
>> reference). Think ComponentGroupRef for example. Something like a
>> ComponentGroupRef will bring in the fragment that defines that
>> ComponentGroupRef into the setup project. Of course, what you need to do in
>> your case will depend on the contents of your wixlib. Presumably there is a
>> setup project getting built by appveyor for the larger project. Can you
>> take a look at that one for an example of how they consume the content of
>> the wixlib?
>>
>> --
>> Edwin G. Castro
>>
>>
>> On Fri, Dec 1, 2017 at 7:38 AM, Jace Malloy via wix-users <
>> wix-users at lists.wixtoolset.org> wrote:
>>
>>> I apologize ahead of time, in that I'm not familiar at all with WiX;
>>> however, in reading some of the documentation in my plight to resolve my
>>> current issue, I see it's power and why it's preferred over the standard
>>> VS
>>> options.
>>>
>>> I'm maintaining a large .NET sub project through Visual Studio 2015,
>>> that's
>>> part of a larger project. The guy before me configured a Wix Setup
>>> Library
>>> (wixlib output) for the smaller, sub project. The sub project is
>>> referenced
>>> through a build process (Appveyor), which creates a MSI file for the
>>> entire
>>> product (the larger project).
>>>
>>> What I need to do is quite simple, but I'm at a loss with what I've tried
>>> thus far. I want to create a MSI file for the sub project component for
>>> testing. I want to do it through Visual Studio to where the build process
>>> outputs a MSI using the existing wixlib.
>>>
>>> I've added a WiX Setup Project to the sub project, but can't figure out
>>> how
>>> to simply reference the existing Setup Library (wixlib). I've added a VS
>>> reference to the Library Project in the Setup Project, but I'm not sure
>>> how
>>> to call the Fragment from the library, from the newer Setup Project.
>>>
>>> Any help is greatly appreciated.
>>>
>>> Thanks all...
>>>
>>> ____________________________________________________________________
>>> WiX Toolset Users Mailing List provided by FireGiant
>>> http://www.firegiant.com/
>>>
>>
>>
>



More information about the wix-users mailing list