Search code examples
visual-studio-2015wixwindows-installerwix3.10wixlib

Trying to move a Wix .wxl file to a Wix .wixlib project


The Setup

So I have two Wix projects, one is our main one with the Product.wxs file in it and the second one is our library of shared .wxs files. Our main Wix project references the the library one. This is also all in a Visual Studio 2015 solution. The main Wix project has also a .wxl file (WixLocalization stuff) in it.

What I'm Trying to Accomplish

I want to move that .wxl file to the library Wix project because it can be shared for other projects as well.

The Issue I'm Running Into

When I copy the file over to the library project and delete the original file in the main project, I get a bunch of compile errors in Visual Studio saying, "The localization variable !(loc.NameOfString) is unknown. Please ensure the variable is defined.". I get this error when I compile the main project. The Wix library one compiles successfully. So because of this I can't create an installer anymore.

What I've Done So Far

I've tried searching for this kind of topic of using a .wxl file in a Wix library project but had no luck.

I've tried digging into if there's some other syntax to use those String values if they are moved to a Wix library besides the "!(loc.StringName)" syntax.

I checked out the project files too to see if there's some reference I need to add or something. The "funny" thing about it is that the String values in the .wxl are only used in .wxs files within the library itself. For example, I have a UI Dialog .wxs file in the library and it uses the "!(loc.Title)" String value from the .wxl file. The Product.wxs file in the main project doesn't use those String values.

I find it very odd that a Wix library project can't find/use a .wxl within itself....

I really do like to get this working in the library so we just have one .wxl file with all the String values we used, so we don't have to keep Copying and Pasting that same file over and over again for other main Wix projects.

Any type of help would be very much appreciated. If I'm not clear enough, please feel free to ask to clarify any confusing details. Please and thank you!


Solution

  • All you need to do is tell the WiX linker which culture to use when building the main project. WiX libraries may contain multiple cultures so you need to pick one.

    As you're using a Visual Studio WiX project, you can simply do this in the property sheet of the project. Right-click > Properties > Build > Cultures to build.

    WiX project properties

    When using the command-line instead, it's the following parameter of "light.exe":

    -cultures:<cultures>  semicolon or comma delimited list of localized
                          string cultures to load from .wxl files and libraries.
                          Precedence of cultures is from left to right.
    

    Example:

    light.exe [other parameters] -cultures:en-US