Can WiX be set to automatically include all generated satellite assemblies?
The goal is to have a single English language MSI that installs an application with localized strings available for ~10 languages.
I found this existing SO quetsion:
How do I include Satellite Assemblies(Localized Resources) in an MSI built with WiX?
However that solution suggests that new component and directory definitions needs to be manually added for each culture variant.
Is that the only way, or can WiX somehow automatically learn about each language from the Visual Studio project definitions?
(Running VS2010 and WiX 3.8)
You can use HarvestDirectory task to automatically collect files to be included in installer. You just need to point it to folder with your satellite assemblies and on each build of installer - target folder will be rescanned and file list will be regenerated.
For example:
1) Place in .wixproj harvest task inside beforedBuild target (it will be commented 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) Build your installer first time. After that you will find SatelliteAsm_Files.wxs file inside your WIX project. It will have structure similar to this:
<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 link (it's important you don't want source control to set this file to read only, coz WIX will fail on build) to your project.
4)Reference this ComponentGroup in any of your features
<Feature Id="MyFeauture">
<ComponentGroupRef Id="GroupName" />
Finally it's ready! Now files collected from folder you specified in harvest task will be included in your installer. But don't expect this to work out of box because it's royal pain to setup this and you may need to try different combinations of task keys or even XSD transformations to leave only needed files (yes WIX can do XSD transforms, and no there is no easy and agile way to filter files or folder harvested by WIX)
Note: you can use it not only for satellite assemblies - it's ok to harvest entire bin, 3rd party libs or whatever you want, so you don't need to update installer project by hand every time you add new assembly to your solution.
来源:https://stackoverflow.com/questions/25489404/wix-how-to-automatically-include-localized-satellite-assemblies