Description
Breaking changes to runtime compilation for Razor views and Razor Pages
Support for runtime compilation of Razor views and Razor Pages is being moved to a separate package.
Version introduced
3.0
Old behavior
Runtime compilation was available without needing any additional packages.
New behavior
The functionality has been moved to Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package.
The following APIs previously available on Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions
to support runtime compilation would now be available via
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation.MvcRazorRuntimeCompilationOptions
:
RazorViewEngineOptions.FileProviders
->MvcRazorRuntimeCompilationOptions.FileProviders
RazorViewEngineOptions.AdditionalCompilationReferences
->MvcRazorRuntimeCompilationOptions.AdditionalReferencePaths
In addition, Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions.AllowRecompilingViewsOnFileChange
has been removed. Recompilation on file changes is enabled by default by referencing the Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package.
Reason for change
To clean up the ASP.NET Core shared framework to not depend on Roslyn.
Recommended action
Applications that require runtime compilation or re-compilation of Razor files should
- Add a reference to the
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package - Update the application's ConfigureServices to include a call to
AddMvcRazorRuntimeCompilation
:
services.AddMvc()
.AddMvcRazorRuntimeCompilation();
Category
ASP.NET Core
Affected APIs
Microsoft.AspNetCore.Mvc.Razor.RazorViewEngineOptions
Issue metadata
- Issue type: breaking-change