Allow configuration of cshtml views runtime compilation #16810
deMD
started this conversation in
Features and ideas
Replies: 1 comment 2 replies
-
Hi.. Thanks for the suggestion. It is definitively something we like to look more into in the future. To my knowledge, we are not allowed to have a dependency to I cannot give any timeframe for when we plan do look into it, but we are about to release a options to the dotnet new templates, that can ease the setup of projects as a regular dotnet developer. More info on the PR #16815 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Currently by default Umbraco installs uses the InMemory Modelsbuilder and Razor Runtime Compilation. This is fine for installs that use the templating engine within Umbraco and thus is ideal for low code solutions. However, as a software developer, since I started working with Umbraco and ever since V7 I always used the Modelsbuilder SourceCodeAuto mode due to the additional complexity I always needed to add to my application (and who doesn't like that sweet sweet intellisense helping you with your model properties?).
With .Net 6 Microsoft also introduced Hot Reload which is an awesome feature can recompile code (and views) at a certain level dynamically without needing to restart the entire application reducing the need for Razor Runtime Compilation in projects utilizing the Source code ModelsBuilder and an IDE.
Also added in .Net 6 was the possibility to utilize css isolation, a feature that allows you to define css files as children of your views which then get dynamically compiled into css during build (or hot reload). However this feature does not work nicely together with Razor Runtime Compilation.
So here is my suggestion: Add a configuration option to disable Razor Runtime Compilation, with the caveat that you can't use the InMemory Modelsbuilder (akin the Production Runtime Mode) eg:
which would, just like the production runtime mode, prevents this piece of code: https://github.com/umbraco/Umbraco-CMS/blob/contrib/src%2FUmbraco.Web.Common%2FDependencyInjection%2FUmbracoBuilderExtensions.cs#L239-L242.
Then all that would need to be done manually is to remove this bit of code in the csproj:
And add this:
It's interesting that I needed to do this though, as a vanilla .Net MVC project template has neither config in the csproj and
dotnet watch
works fine for cshtml then.This change would prevent users to have to use the current workaround:
Beta Was this translation helpful? Give feedback.
All reactions