Reputation: 1704
I am attempting to serve an API and Angular Front-End with an ASP.NET Core 2.1 backend. Startup.cs
is in the project MyApp.Api
. I want my static files to be pulled from the wwwroot of another project, MyApp.FrontEnd
.
I have seen this post which describes the following method
app.UseStaticFiles(new StaticFileOptions {
FileProvider = new EmbeddedFileProvider(
assembly: Assembly.Load(new AssemblyName("OpenIddict.Assets")),
baseNamespace: "OpenIddict.Assets")
});
However, when I try to replace "OpenIddicts.Assets" with my project name, I get the following error:
FTL Application startup exception System.IO.FileNotFoundException: Could not load file or assembly 'MyApp.FrontEnd, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified. File name: 'MyApp.FrontEnd, Culture=neutral, PublicKeyToken=null'
The GitHub repository referenced in the post linked above seems to no longer exist. I assume I'm missing somewhere fairly obvious. Any help would be appreciated.
Upvotes: 1
Views: 2850
Reputation: 548
MyApp.FrontEnd.dll
must exist in output folder. If You publish main project (which has reference to MyApp.FrontEnd
) then everything should work.
If you have access to some types from assembly then you can try Assembly.GetAssembly(type)
instead of Assembly.Load(...)
, i.e.
app.UseStaticFiles(new StaticFileOptions {
FileProvider = new EmbeddedFileProvider(
assembly: Assembly.GetAssembly(typeof(SomeClassFromAssembly)),
baseNamespace: "OpenIddict.Assets")
});
Upvotes: 1