Consider adding an option to the MVC \ Razor Pages template that enables runtime compilation by default
See original GitHub issueAs part of .NET Core 3.0, runtime compilation of views and Razor Pages was moved to a separate package. Our migration guide has a section that deals with re-adding runtime compilation to their projects. Reloading views on file changes relies on VS which only works when the debugger is not attached,
We’ve had several reports of users being surprised or confused when changes to the views aren’t being picked up. This is understandable given users are accustomed to entering <kbd>F5</kbd> in their IDEs and expect things to just work.
One possible way to make this a bit nicer is to have a switch during project creation that enables runtime compilation.
A couple of things to note:
- The feature requires templating changes with no runtime changes.
- We would need to surface this experience as a UI gesture (a checkbox) during the VS project creation dialog.
- We do not want runtime compilation on in non-development environments (runtime compilation results in using the file watcher + blocking async calls both of which are problematic). Having the package reference also results in additional reference assemblies being produced in the build and publish output which we worked hard to eliminate in the 3.0 release. Could we do something more in the templates than adding it behind the
IsDevelopment
flag to minimize the impact on published apps?
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Razor file compilation in ASP.NET Core
Build-time and publish-time compilation of Razor files is enabled by default by the Razor SDK. When enabled, runtime compilation complements ...
Read more >Adding AddRazorRuntimeCompilation() to the container in ...
I was struggling the same problem as well, while trying the versions of Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation nuget package and ...
Read more >Enable Razor Runtime Compilation
This article/tutorial will show you how to enable runtime compilation when creating ASP.NET Core and ASP.NET Core MVC projects.
Read more >Razor file compilation in ASP.NET Core
The Razor Pages and MVC project templates include an option to enable runtime compilation when the project is created. This option is supported...
Read more >Add Razor runtime compilation when developing ASP.NET Core
Runtime compilation of Razor files just worked out of the box with ASP.NET MVC. In this post, I'll show you how we solved...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Verified. For users starting with a new application, both the CLI and VS offer an option to enable runtime compilation. For users updating, here are the two steps required to enable runtime compilation only during development:
a) Add a PackageReference to
Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
version 3.1.3 or newer. b) UpdatelaunchSettings.json
to include aASPNETCORE_HOSTINGSTARTUPASSEMBLIES
environment variables:Fixed as part of https://github.com/dotnet/aspnetcore/pull/18648