According to https://docs.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.0 by default razor views should recompile on change on local environments for asp.net core 3.0.
However, my project doesn't do this locally. If I change a view and refresh when I'm debugging locally, the change does not reflect. I have to stop the solution, re-run, and then see the change.
I am doing this on a default ASP.NET Core Web Application template on Visual Studio 2019 with asp.net core 3.0.0 preview 2 using razor pages. Any idea if I need to change settings to enable this feature?
OK it looks like it's not supported yet :(
Runtime compilation removed As a consequence of cleaning up the
ASP.NET Core shared framework to not depend on Roslyn, support for
runtime compilation of pages and views has also been removed in this
preview release. Instead compilation of pages and views is performed
at build time. In a future preview update we will provide a NuGet
packages for optionally enabling runtime compilation support in an
app.
You can read more about the issue here https://github.com/aspnet/Announcements/issues/343
Applications that require runtime compilation or re-compilation of Razor files should:
- Add a reference to the
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
package. It'll be available as part of the 3.0.0-preview3 release.
- Update the application's
ConfigureServices
to include a call to AddMvcRazorRuntimeCompilation
:
To get runtime view compilation back in ASP.NET Core
3
- Reference
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
- Call
services.AddMvc().AddRazorRuntimeCompilation()
- Remove
Microsoft.VisualStudio.Web.CodeGeneration.Design
if there's a version mismatch on the Microsoft.CodeAnalysis.Common
package