Automated build of Satellite Assemblies in Visual Studio with MSBUILD

Automated build of Satellite Assemblies in Visual Studio with MSBUILD

  • Comments 2

Download sample code

Much has been said and written about satellite assemblies and localization techniques that are achieved using them.  I believe that most of the industry has no doubt in the usefulness of this amazing feature of the .NET Framework; however the lack of automation has made it slightly difficult for many companies to adopt. (In Visual Studio 2005 the generation of satellite assemblies for controls placed on Windows Forms is an automated process. Just use the localized property in conjunction with the language property of Forms. This is not covered in this blog entry).

Just to demonstrate how simple it is to automate the creation and build of these assemblies, I have put together a simple application which uses MSBUILD and post-build events to automatically generate resources and link them into satellite assemblies.

With satellite assemblies, they need to be placed in a specific directory structure. See http://msdn2.microsoft.com/en-us/library/21a15yht(vs.80).aspx for more information on this structure.

The first step in creating a satellite assembly is to compile .resx files into .resources files. This is usually done using the RESGEN utility or the GenerateResource MSBUILD task:

Resgen.exe /compile SatelliteAssembly.en-GB.resx,SatelliteAssembly.en-GB.resources

<GenerateResource Sources="@(Res)"/>

The second step is to use the assembly linker utility to create the satellite assembly from .resources files:

AL.exe /culture:en-GB /out:en-GB\SatelliteAssembly.resources.dll /version:1.0.0.0 /embed:SatelliteAssembly.en-GB.resources

<AL OutputAssembly="%(Culture)\SatelliteAssembly.resources.dll"

        Version="1.0.0.0"

        Culture="%(Culture)"

        EmbedResources="@(Resources)"/>

The MSBUILD script is called by the post-build event of the executable project and here is what it does:

-          MSBUILD script is executed by the post-build event of the executable project passing the path to the output directory

-          .resx files are compiled into .resources

-          .resources are linked into satellite assemblies

-          Satellite assemblies are copied to the output folder

-          All temporary files and folders are deleted

Attachment: SatelliteAssembly.zip
Leave a Comment
  • Please add 8 and 5 and type the answer here:
  • Post
  • How do you make ASP.NET copy your lovely satellite assembly properly into the funny naming scheme of its shadow copy mechanism?

  • Is it possible to generate the satellite assembly without specifying the culture name and .resx in the ItemGroup section.Instead scan the entire folder for any .resx files and generate satellite assembly for these.

Page 1 of 1 (2 items)