Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I include a Wix fragment by referencing a property defined in it?

Tags:

wix

I'm using Wix 3.8. I have a Wix library, and in its wxs file I have a Fragment which has a property:

<Fragment>
  <!-- The following property is only used for reference -->
  <Property Id="ReferenceProp"></Property>

  <!-- other stuff here ... -->
</Fragment>

In my setup project I want to use the contents of this fragment, but I want to do it in an easy way, so I tried adding a PropertyRef to to the ReferenceProp property defined above. I got an error:

Unresolved reference to symbol 'Property:ReferenceProp'

However, if I change said property to be a ComponentGroup (and the ref to a ComponentGroupRef) then it works. Is this a bug? Is it designed to work in that unintuitive way? Or did I miss something?

Edit: to be clear I did have my PropertyRef inside my Product element when I got the above error.

Edit2: I knew I had seen some info before explicitly stating I could use PropertyRef to pull in a fragment. Here is the quote from the book Wix 3.6 A developer's Guide to Windows Installer XML by Nick Ramirez:

For example, properties, which are variables that you can use to store data, are represented by Property elements and could be stored in a separate file within a Fragment element. Then, by referencing just one of them in your main source file with a PropertyRef element, you'd pull all of them into your project."

Either that book is wrong, or this was a feature that they removed, or a newly introduced bug.

like image 944
user145400 Avatar asked Mar 18 '23 11:03

user145400


1 Answers

You need to link to one component to load a whole fragment.

To quote John Cooper:

You need a reference element to any one bit inside the fragment. The way Wix linking currently works, a linkage to one item in a fragment brings in the whole fragment.

For example, if you have a Component element in a fragment, you would link in the fragment using a ComponentRef with the appropriate Id attribute.

And Ian Williams

Yep, you need to reference something in a fragment (DirectoryRef, ComponentRef, etc) to load the fragment (it will all be loaded, note).

Also remember to include allt he .wxs files in your call to candle and light

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/How-to-reference-a-wxs-file-from-another-td7334084.html

Edit

It is possible with PropertyRef too. I just checked it myself. Change this:

<Property Id="ReferenceProp"></Property>

To this:

<Property Id="ReferenceProp" Value="1" />

You need to set a value.

like image 163
Aaron Avatar answered Apr 27 '23 14:04

Aaron