Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Automatically embeds satellite assembly as resources during build

License

Notifications You must be signed in to change notification settings

SubmergedAmongUs/Resource.Embedder

 
 

Repository files navigation

This repo has been modified for personal use.

If you want to use this project, please use the upstream version instead.


Automatically embeds satellite assemblies into the main assembly

Compatible with .Net Standard 2.0 and .Net 4.6 and above.

⚠️ As of .Net Core 3 single-file publishing exists as an alternative. Where possible consider using it instead of the Resource embedder!

Read single-file executables for more details.

Going forward

Single-file executables technically make the Resource Embedder project obsolete, although there are some use cases (e.g. manually inject resources) that aren't (yet) covered natively by .Net Core.

For now no new features are planned for the resource embedder but I will continue to bugfix where the effort is appropriate.

NuGet references

Resource.Embedder NuGet Status

By adding the NuGet package to an assembly all it's satellite assemblies will automatically be embedded as resources and loaded from there. Each assembly with localization files needs to reference the embedder package!

Resource.Embedder.Core NuGet Status

Only use the Core package if you want to manually inject resources!

How it works

Before: Localization files (<Exe name>.resources.dll) are in seperate folders per language:

before

After adding the nuget and recompiling: No more seperate files, all localization resources are embedded into exe/dll and are loaded automatically:

after

Why?

By embedding localization files it is possible to create "zero dependency" executables that can simply be deployed and "just run".

When using resource embedder also consider using Costura to embed reference assemblies (which cannot embed satellite assemblies due to the way it's integrated into the build process).

Links

Verify it works

Once ran, the resource files should disappear from the build output and the Output log will contain messages confirming that the files have been embedded.

The output project will still be properly localized.

Using tools like dnSpy it is possible to see that any project using this package contains resources "<AssemblyName>.<culture>.resources.dll"

Configuration

Currently nothing can be configured and it "just works" out of the box.

Output directory

Note that the satellite assemblies are always copied to the output directory by Visual Studio.

After the build finishes the Resource.Embedder will delete all resource files it has embedded, leaving only the resource files that have not been embedded (if any).

If there are no resource files left for a specific language (empty localization directory) the directory is deleted as well.

About

Automatically embeds satellite assembly as resources during build

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Languages

  • C# 99.9%
  • ASP.NET 0.1%