For use by Umbraco package developers to serve embedded resources.
The NuGet package installs a single assembly Our.Umbraco.EmbeddedResource.dll.
Using embedded resources within an assembly for a package has some of advantages:
-
No need to split a package into two NuGet packages to prevent \App_Plugins*.* files from added into a class library project.
-
There's nothing to add into source control (other than a NuGet reference) for the end consumer.
-
Resources can be protected so that they are only served to back office authenticated users (no leakage as to what packages are installed).
The embedded resources in your project need to be registered and this is done via assembly attributes (typically placed in /Properties/AssemblyInfo.cs).
There are two assembly attributes:
Both attributes have the same two required parameters:
- The full namespace path to the embedded resource
- The app relative url that the resource should be served on
@using Our.Umbraco.EmbeddedResource
// register an embedded jpg as if it were on the file system
[assembly: EmbeddedResource("MyPackage.Example.jpg", "/App_Plugins/MyPackage/Example.jpg")]
// register an embedded png, served only to back office users
[assembly: EmbeddedResourceProtected("MyPackage.Example.png", "/App_Plugins/MyPackage/Example.png")]