1

We're updating some old WiX scripts to take advantage of the Feature attribute of components, so that we don't have to update the file in two places whenever we add or remove a component (once to add the Component and again to add a ComponentRef to the ComponentGroup).

We separate out WiX project into separate files, one per fragment to make things more manageable. But my fragment defining the components for a feature is no longer getting included. It sounds identical to Tomas's issue in his response to the Feature attribute announcement. But while he is using Heat to auto-generate his Wix file, we're manually crafting them from scratch.

I tried creating a dummy property in the fragment's .wxs file and then referencing it in the main .wxs within the Product element. The fragment was still not included and I got an invalid property ID.

We initially tried using the strategy described here to reference directories in the component, but while this eliminates the need for a separate ComponentGroup full of ComponentRefs, it also separates my component definition from the directory tree definition, which kind of defeats the purpose of only needing to look in one place to do an update.

Will I need to pull all of my fragments into the main Product.wxs file simply to take advantage of the Feature attribute, and avoid having to update the file in two places per component? Or is there an easy way to get the fragment to include? Again using a dummy property reference didn't seem to work.

Edit: I think I found the issue in my build--I had defined a Directory under the Product Tag and then a DirectoryRef in the Fragment, rather than the other way around.

1 Answer 1

3

Take a look at how we authored the WiX setup itself: Author Components under ComponentGroups and use ComponentGroupRef to pull those into Features. That eliminates most duplication. You can author Directory and DirectoryRef elements in fragments in the same file as your Components/ComponentGroups.

Sign up to request clarification or add additional context in comments.

5 Comments

I see you guys use the Directory attribute as mentioned in my question. So there's no neat way to author a Component under a Directory (so that the files are in their directory context, rather than separate section from the directories) and tie them to features using the Feature attribute? We could do this if we could just get the fragment file containing the components to be included.
Like I said six years ago: 'As Derek told me when I ran into the same problem: “Parents can pick their children, but children can’t pick their parents.”' As generally there are fewer Directory elements than Component elements, the language doesn't optimize for the authoring you want.
Right--I've read that quote, it's a good quote, but shouldn't I be able to pull in a fragment using a PropertyRef (for example) on a property defined in the fragment? I'm not sure why that doesn't work to include the fragment, or if there's another way to do so. Only ComponentRef will include a fragment?
PropertyRef will pull in a fragment. If it doesn't hook up Component/@Feature, that's a bug in the WiX linker.
Just built a minimal project using PropertyRef as the only means of pulling in a fragment. It works though! Doing this helped me find the issue in my build--I had defined a Directory under the Product Tag and then a DirectoryRef in the Fragment, rather than the other way around. Thanks for your help!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.