[wix-users] moving UI code into a fragment in separate source file
Jason Beck
mrbass21 at gmail.com
Sun Oct 1 14:22:59 PDT 2017
Alan,
I'm newer to using WiX, so anyone who reads this and notices I say
something incorrect, please reply with a correction so that we all
benefit from it.
You can use fragments with your components and UI. I, like you, don't
like the idea of just using include to dump the file mentioned into your
Project.wxs.
The answer to your question is actually much easier than you might
think. You just use a Ref counterpart to a specific tag.
Lets say you have UI.wxs with your UI WiX code and Product.wxs with all
other WiX code. In UI you will have used the <UI Id="CustomUIWizard">
tag to define the start of your UI. How do you pull this into your main
Product.wxs file? You use the ref counterpart. Anywhere inside of your
<Product ...> tag, just use <UIRef ID="CustomUIWizard" />.
When you reference ANY item with it's Ref Counterpart (PropertyRef,
ComponentRef, ComponentGroupRef, etc), you will pull the WHOLE fragment
into scope. So when you use UIRef for CustomUIWizard example above,
everything in that fragment inside UI.wxs is pulled into the scope of
Product.wxs.
You can even do this trick for items that don't have a ref counterpart,
like <Condition>. You could define conditions inside a fragment for
Condition.wxs file. Since there is no ConditionRef to use to pull it
into Product.wxs, you can "cheat" by creating a property inside
Condition.wxs, <Property Id="ConditionReference">, and then (since
Property has a PropertyRef counterpart) use a <PropertyRef ...> in your
Product.wxs to pull all those conditions into scope.
Again, be careful with this because everything in that fragment tag will
be pulled into scope, so if you had one condition for ProductA.wxs and
one condition for ProductB.wxs inside of that Condition.wxs file as a
common location, and they were mutually exclusive, referencing ether
condition in ProductA or ProductB would include both the conditions.
I highly recommend Nick Ramirezs book WiX 3.6: A Developer's Guide to
Windows Installer XML. It's an easy read and has lot's of extremely
helpful information, and despite being for an "old" version of WiX, is
still incredibly relevant. That's where I learned everything listed above.
On 10/1/2017 1:44 PM, Alan Sinclair via wix-users wrote:
> thanks Joseph & David .. yes I'll use <?include..>
>
> I'm using fragments for components with several separate source files, so
> was stuck on that idea but couldn't figure a way to make a reference to the
> overall UI section. Include will do fine.
>
> thanks
> Alan
>
> On Sun, Oct 1, 2017 at 12:19 AM, David Watson via wix-users <
> wix-users at lists.wixtoolset.org> wrote:
>
>> Include is for inserting code inline (usually small repeated fragments).
>>
>> If you want to split your code into manageable chunks just author several
>> wxs files and add them to the wixproj (or command line if you build that
>> way).
>>
>> Any time you make a reference across a fragment - whatever file it is in -
>> the linker will link in all the relevant parts.
>>
>> Dave
>>
>>
>> www.sdl.com
>> SDL PLC confidential, all rights reserved. If you are not the intended
>> recipient of this mail SDL requests and requires that you delete it without
>> acting upon or copying any of its contents, and we further request that you
>> advise us.
>> SDL PLC is a public limited company registered in England and Wales.
>> Registered number: 02675207.
>> Registered address: Globe House, Clivemont Road, Maidenhead, Berkshire SL6
>> 7DY, UK.
>> -----Original Message-----
>> From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf
>> Of Joseph L. Casale via wix-users
>> Sent: 01 October 2017 08:02
>> To: 'WiX Toolset Users Mailing List' <wix-users at lists.wixtoolset.org>
>> Cc: Joseph L. Casale <jcasale at activenetwerx.com>
>> Subject: Re: [wix-users] moving UI code into a fragment in separate source
>> file
>>
>> -----Original Message-----
>> From: wix-users [mailto:wix-users-bounces at lists.wixtoolset.org] On Behalf
>> Of Alan Sinclair via wix-users
>> Sent: Saturday, September 30, 2017 10:30 PM
>> To: WiX Toolset Users Mailing List <wix-users at lists.wixtoolset.org>
>> Cc: Alan Sinclair <anadem at gmail.com>
>> Subject: [wix-users] moving UI code into a fragment in separate source file
>>
>>> I'm going to need to extend the installer UI so want to move that code
>>> into a separate source file, gui.wxs. I assume it will be a fragment
>>> but how do I reference it so it's included in the MSI? (Sorry, this
>>> feels like a really dumb question!)
>>
>> Use an include preprocessor, see http://wixtoolset.org/
>> documentation/manual/v3/overview/preprocessor.html
>> That literally inserts what's wrapped in the include element from the
>> referenced code into the spot the PP directive exists.
>>
>> ____________________________________________________________________
>> WiX Toolset Users Mailing List provided by FireGiant
>> http://www.firegiant.com/
>>
>> ____________________________________________________________________
>> WiX Toolset Users Mailing List provided by FireGiant
>> http://www.firegiant.com/
>
> ____________________________________________________________________
> WiX Toolset Users Mailing List provided by FireGiant http://www.firegiant.com/
>
More information about the wix-users
mailing list