Add runtime mode (BackofficeDevelopment, Development and Production) (#12631)

* Add runtime mode setting

* Only enable Razor runtime compilation in development modes

* Only enable ModelsBuilder generation in development modes

* Fix disabling ModelsBuilder controllers

* Add IRuntimeModeValidationService and IRuntimeModeValidator

* Add JITOptimizerValidator

* Add UmbracoApplicationUrlValidator

* Add UseHttpsValidator

* Add RuntimeMinificationValidator

* Add ModelsBuilderModeValidator

* Remove .NET 6 preview 1 fix for Razor runtime compilation

* Only allow InMemoryAuto in backoffice development mode

* Make runtime mode validators public, so they can be easily removed if required

* Add comment to highlight removing RazorCompileOnBuild, RazorCompileOnPublish and CopyRazorGenerateFilesToPublishDirectory when using ModelsMode InMemoryAuto

* Add documentation

* Update src/Umbraco.Web.Common/ModelsBuilder/NoopModelsBuilderDashboardProvider.cs

Co-authored-by: Ronald Barendse <ronald@barend.se>

Co-authored-by: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
This commit is contained in:
Ronald Barendse
2022-07-01 08:48:05 +02:00
committed by GitHub
parent 7d545a7dfc
commit dca4d0f167
25 changed files with 791 additions and 420 deletions

View File

@@ -0,0 +1,22 @@
namespace Umbraco.Cms.Core.Configuration.Models;
/// <summary>
/// Represents the configured Umbraco runtime mode.
/// </summary>
public enum RuntimeMode
{
/// <summary>
/// The backoffice development mode ensures the runtime is configured for rapidly applying changes within the backoffice.
/// </summary>
BackofficeDevelopment = 0,
/// <summary>
/// The development mode ensures the runtime is configured for rapidly applying changes.
/// </summary>
Development = 1,
/// <summary>
/// The production mode ensures optimal performance settings are configured and denies any changes that would require recompilations.
/// </summary>
Production = 2
}

View File

@@ -1,16 +1,24 @@
// Copyright (c) Umbraco.
// See LICENSE for more details.
using System.ComponentModel;
namespace Umbraco.Cms.Core.Configuration.Models;
/// <summary>
/// Typed configuration options for runtime settings.
/// Typed configuration options for runtime settings.
/// </summary>
[UmbracoOptions(Constants.Configuration.ConfigRuntime)]
public class RuntimeSettings
{
/// <summary>
/// Gets or sets a value for the maximum query string length.
/// Gets or sets the runtime mode.
/// </summary>
[DefaultValue(RuntimeMode.BackofficeDevelopment)]
public RuntimeMode Mode { get; set; } = RuntimeMode.BackofficeDevelopment;
/// <summary>
/// Gets or sets a value for the maximum query string length.
/// </summary>
public int? MaxQueryStringLength { get; set; }