I just have started looking into .Net Core, and I don\'t see classical resources and anything what looks like resources. In classical .Net class libraries I was able to add,
UPDATE:
.NET Core 1.1 and later have dropped project.json
and returned to .csproj
files.
This changes Step 2, but not all that much. The necessary lines are very similar:
There may be a similar *.tff
form; unconfirmed.
Steps 1 and 3 are unchanged.
To use embedded resources in .NET Core 1.0 project do the following:
Add your embedded file(s) as usual.
Example: some FONT files on a directory named "_fonts"
Modify "project.json" to include the related resources.
In my case:
"buildOptions": {
"embed": {
"include": [
"_fonts/*.ttf"
]
}
},
Access the embedded resource in code.
var assembly = typeof(MyLibrary.MyClass).GetTypeInfo().Assembly;
Stream resource = assembly.GetManifestResourceStream("MyLibrary._fonts.OpenSans.ttf");
The key point is to use the right name on GetManifestResourceStream call. You have to use [assembly name].[directory].[file name]
.