The documentation describes how to set up a static file serving any directory.
The solution to my problem was to switch the directory from which static files could be loaded based on such a hosting environment:
public class Startup { private IHostingEnvironment env; public Startup(IHostingEnvironment env) { this.env = env; } public void Configure(IApplicationBuilder app) { if (env.IsDevelopment()) { var webRootPath = env.WebRootPath; var webSrcPath = webRootPath + @"\..\wwwsrc"; app.UseDefaultFiles(new DefaultFilesOptions() { FileProvider = new PhysicalFileProvider(webSrcPath), RequestPath = new PathString("") }); app.UseStaticFiles(new StaticFileOptions() { FileProvider = new PhysicalFileProvider(webSrcPath), RequestPath = new PathString("") }); } else { app.UseDefaultFiles(); app.UseStaticFiles();
With this setting, I can place all my external attributes (html, javascript, css) in wwwsrc and serve them raw during development from this directory.
My external assembly (based on gulp) then processes the assets in wwwsrc and puts optimized assets (concatenated, minimized, verified and html-adjusted links) in wwwroot .
If I want to test the release build, I can serve from wwwroot .
Switching between the debug and release builds can be done by setting the ASPNET_ENV environment ASPNET_ENV in the debug profile (Project β Properties β Debug or in the file Properties/launchSettings.json ).
Thanks to @Maxime Rouiller for pointing me in the right direction in his answer.
source share