3

I have added resources for different cultures to my Class Library Project. When building, seperate folders are created for each culture with an assembly in each of them.

Is there a way to embed all the resources in the Class Library Assembly, instead of having an extra assembly for each culture? The class library is eventually used in another project, so with theses seperate folders, it need to distribute a zip file instead of just one assembly.

Clarification: I was looking for a solution without installers or second party tools. Rather was I hoping for a solution inside Visual Studio where the outcome would be one assembly with the different resources in it.

Lieven Cardoen
  • 25,140
  • 52
  • 153
  • 244
  • 2
    At first I thought this is not possible (since the assemblies are using the same namespace) but after a quick search I run into [this](http://stackoverflow.com/questions/1952638/single-assembly-multi-language-windows-forms-deployment-ilmerge-and-satellite-a) – Menelaos Vergis Mar 26 '14 at 14:06
  • 3
    You embed assemblies in a program called *setup.exe*. Don't write your own installer, there are umpteen installer builder tools readily available. Including Visual Studio's Publish tab. – Hans Passant Mar 26 '14 at 14:09
  • Strange that there's no 'easy' method to do this. Thx. – Lieven Cardoen Mar 26 '14 at 14:24
  • 1
    Keep in mind that having different cultures in different assemblies makes it easier for Windows to choose the appropriate resources for the user. Overriding the data decision means writing code to handle it, which is a possible entry point for bugs. As mentioned, the best bet is to just use something like [NSIS](http://nsis.sourceforge.net/Main_Page) (which has a few decent IDEs such as [HMNE](http://hmne.sourceforge.net/)) or ClickOnce, which takes care of the work for you. Less work and less risk. – John C Mar 26 '14 at 14:34
  • 2
    The question should be clarified. As I understand it, the point is not to make an installer or anything the like. Rather, the OP wants to end up with a single dll that has multi-language capabilities. Similar to [this question](http://stackoverflow.com/questions/7488921/embedding-localization-resources-dlls-to-the-executable-in-c) or [this one](http://stackoverflow.com/questions/1793256/how-to-embed-multilanguage-resx-or-resources-files-in-single-exe) except for DLLs not EXEs. – Andreas Mar 26 '14 at 15:11

1 Answers1

2

To murge multiple assemblys into one you can use Fody/Costura. It allows you to merge multiple assemblys into 1 project. In your main project you add it(can be done via nuget). Then just in weavers.xml (file that will be automaticly generated add these text:

<Costura>
    <IncludeAssemblies>
        Project.MyData.Dutch
        Project.MyData.French
        Project.MyData.English
    </IncludeAssemblies>
</Costura>

(it should be the same name as the reference, so without the .dll suffix)

Maximc
  • 1,722
  • 1
  • 23
  • 37