Skip to content

Commit 23e816c

Browse files
committed
Extended run-time compilation to Razor Class Library
By default, run-time compilation only affects the local views. With the help of the `FileProviders` option, however, we can additionally watch and compile the views from the Razor Class Library, which is in a separate project than the run-time host.
1 parent 78d1485 commit 23e816c

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

OnTopic.Editor.AspNetCore.Host/Startup.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ public void ConfigureServices(IServiceCollection services) {
9090
\-----------------------------------------------------------------------------------------------------------------------*/
9191
if (HostingEnvironment.IsDevelopment()) {
9292
mvcBuilder.AddRazorRuntimeCompilation();
93+
services.Configure<MvcRazorRuntimeCompilationOptions>(options => {
94+
var libraryPath = Path.GetFullPath(Path.Combine(HostingEnvironment.ContentRootPath, "..", "OnTopic.Editor.AspNetCore"));
95+
options.FileProviders.Add(new PhysicalFileProvider(libraryPath));
96+
});
9397
}
9498

9599
/*------------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)