WiX: how to automatically enable localized satellite assemblies?

Can WiX be set to automatically turn on all generated satellite assemblies?

The goal is to have a single English MSI that installs the application with localized strings available for ~ 10 languages.

I found this existing SO quetsion:

How to enable satellite builds (localized resources) in MSI built with WiX?

However, this solution assumes that new component and catalog definitions must be added manually for each crop variant.

Is this the only way, or does WiX somehow automatically learn about each language from the Visual Studio project definitions?

(Running VS2010 and WiX 3.8)

+3


source to share


1 answer


You can use the HarvestDirectory task to automatically collect files to be included in the installer. You just need to point it to your satellite builds folder and on each installer build. The target folder will be copied and the file list will be restored.

For example:

1) Put in .wixproj the harvest task inside the beforedBuild target (it will be commented out by default)

<Target Name="BeforeBuild">
<HeatDirectory OutputFile="SatelliteAsm_Files.wxs" Directory="$(SolutionDir)PathToYourAssemblies" DirectoryRefId="MODULELOCATION" ComponentGroupName="Modules" SuppressCom="true" SuppressFragments="true" SuppressRegistry="true" SuppressRootDirectory="true" AutoGenerateGuids="false" GenerateGuidsNow="true" ToolPath="$(WixToolPath)" PreprocessorVariable="var.ApplicationModuleDir" SuppressUniqueIds="True" />

      

2) First create your installer. After that, you will find the SatelliteAsm_Files.wxs file in your WIX project. It will look like a structure:



<Fragment>
    <DirectoryRef Id="DIRVARIABLE">
        <Directory Id="dir8B97956DEA791D69AB336941C9163652" Name="x64">
            <Component Id="cmpE72E1056FC8A2AE97260E772A6386763" Guid="{481FF1F3-7AFF-4C17-9AE0-5347BEEB3726}">
                <File Id="filACCD137532BB3AE1F4B3BC207018585B" KeyPath="yes" Source="$(var.ApplicationLibDir)\x64\name.txt" />
            </Component>
            ...
<Fragment>
    <ComponentGroup Id="GroupName">
        <ComponentRef Id="cmpE72E1056FC8A2AE97260E772A6386763" />
        ...

      

3) Add it as a reference (it is important that the source does not control the source code so that this file is read-only, otherwise WIX will crash) to your project.

4) Link to this group of components in any of your functions

 <Feature Id="MyFeauture">
    <ComponentGroupRef Id="GroupName" />

      

Finally, it's ready! The files harvested from the folder specified in the harvest task will now be included in your installer. But don't expect this to work out of the box because it's a royal pain to set this up and you may need to try different combinations of task keys or even XSD transformations to keep only the files you need (yes, WIX can do XSD transformations, and there is no easy and flexible way to filter files or folders collected by WIX)

Note. You can use it for more than just satellite builds - it's okay to build all the bit, third party libraries or whatever you need, so you don't have to update the installer project manually every time you add a new build to your solution.

0


source







All Articles