To read an embedded text file in a .NET Standard 2.0 project use the following code snippet.

1
2
3
4
5
6
7
8
9
10
11
string file;
var assembly = typeof({YOUR_CLASS_NAME}).GetTypeInfo().Assembly;

using (var stream = assembly.GetManifestResourceStream("{YOUR_NAMESPACE}.{FILE_NAME}.txt"))
{
using (var reader = new StreamReader(stream))
{
file = reader.ReadToEnd();
}
}
return file;

To aid in debugging assembly.GetManifestResourceNames() will return the names of all the embedded resources in an assembly.