Maybe duplicate of this already, but since that post does not have any answer, I am posting this question.
The new Razor Class Library is awesome, but it cannot pack
I reached this issue long time ago. You may follow the article how to include static files in a razor library that explains how to get around this issue.
The solution I reached after a lot of investigation is not far from the accepted answer in this question:
netcoreapp2.1
true
(you can find more details in the linked article, even automatize this search from this article )
// first we get the assembly in which we want to embedded the files
var assembly = typeof(TypeInFeatureAssembly).Assembly;
// we filter only files including a wwwroot name part
filePaths = (from rn in assembly.GetManifestResourceNames().Where(rnn => rnn.Contains(".wwwroot."))
let hasArea = rn.Contains(".Areas.")
let root = rn.Substring(0, rn.LastIndexOf(".wwwroot.") + ".wwwroot.".Length)
let rootPath = !hasArea ? root : root.Substring(0, root.IndexOf(".Areas."))
let rootSubPath = !hasArea ? "" : root.Substring(root.IndexOf(".Areas.")).Replace('.', '/')
select hasArea ? rootSubPath.Substring(1, rootSubPath.Length - 2) : "wwwroot" )
.Distinct().ToList();
This extracts all embedded resources in a wwwroot folder located in a relevant path.
var allProviders = new List();
allProviders.Add(env.WebRootFileProvider);
allProviders.AddRange(filePaths.Select(t => new ManifestEmbeddedFileProvider(t.Assembly, t.Path)));
env.WebRootFileProvider = new CompositeFileProvider(allProviders);