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:
1 Set the files as embedded resources
<ItemGroup>
<EmbeddedResource Include="wwwroot\**\*" />
<EmbeddedResource Include="Areas\*\wwwroot\**\*" />
</ItemGroup>
2 Include static files in the manifest
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>
3 Find the relevant folders
(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.
4 Add the found paths to the webroot file provider
var allProviders = new List<IFileProvider>();
allProviders.Add(env.WebRootFileProvider);
allProviders.AddRange(filePaths.Select(t => new ManifestEmbeddedFileProvider(t.Assembly, t.Path)));
env.WebRootFileProvider = new CompositeFileProvider(allProviders);
EmbeddedFileProvider
)../../shared_wwwroot/
). This way changing a single place and applies to all websites.