Post merge fixes

This commit is contained in:
Bjarke Berg
2020-09-07 15:28:58 +02:00
parent e5bb9a22d0
commit 3efee8284a
7 changed files with 85 additions and 76 deletions

View File

@@ -10,24 +10,20 @@ namespace Umbraco.Web.Common.AspNetCore
{
public class AspNetCoreHostingEnvironment : Core.Hosting.IHostingEnvironment
{
private readonly HostingSettings _hostingSettings;
private IOptionsMonitor<HostingSettings> _hostingSettings;
private readonly IWebHostEnvironment _webHostEnvironment;
private string _localTempPath;
public AspNetCoreHostingEnvironment(IOptionsMonitor<HostingSettings> hostingSettings, IWebHostEnvironment webHostEnvironment)
{
_hostingSettings = hostingSettings.CurrentValue ?? throw new ArgumentNullException(nameof(hostingSettings));
_hostingSettings = hostingSettings ?? throw new ArgumentNullException(nameof(hostingSettings));
_webHostEnvironment = webHostEnvironment ?? throw new ArgumentNullException(nameof(webHostEnvironment));
SiteName = webHostEnvironment.ApplicationName;
ApplicationId = AppDomain.CurrentDomain.Id.ToString();
ApplicationPhysicalPath = webHostEnvironment.ContentRootPath;
//TODO how to find this, This is a server thing, not application thing.
ApplicationVirtualPath = _hostingSettings.ApplicationVirtualPath?.EnsureStartsWith('/')
?? "/";
IISVersion = new Version(0, 0); // TODO not necessary IIS
}
@@ -37,8 +33,9 @@ namespace Umbraco.Web.Common.AspNetCore
public string ApplicationPhysicalPath { get; }
public string ApplicationServerAddress { get; }
public string ApplicationVirtualPath { get; }
public bool IsDebugMode => _hostingSettings.Debug;
//TODO how to find this, This is a server thing, not application thing.
public string ApplicationVirtualPath => _hostingSettings.CurrentValue.ApplicationVirtualPath?.EnsureStartsWith('/') ?? "/";
public bool IsDebugMode => _hostingSettings.CurrentValue.Debug;
public Version IISVersion { get; }
public string LocalTempPath
@@ -48,7 +45,7 @@ namespace Umbraco.Web.Common.AspNetCore
if (_localTempPath != null)
return _localTempPath;
switch (_hostingSettings.LocalTempStorageLocation)
switch (_hostingSettings.CurrentValue.LocalTempStorageLocation)
{
case LocalTempStorage.AspNetTemp:

View File

@@ -34,7 +34,7 @@ namespace Umbraco.Web.Common.Builder
{
options.ShouldProfile = request => false; // WebProfiler determine and start profiling. We should not use the MiniProfilerMiddleware to also profile
}));
public static IUmbracoBuilder WithMvcAndRazor(this IUmbracoBuilder builder, Action<MvcOptions> mvcOptions = null, Action<IMvcBuilder> mvcBuilding = null)
=> builder.AddWith(nameof(WithMvcAndRazor), () =>
{

View File

@@ -29,6 +29,8 @@ using Umbraco.Web.Common.AspNetCore;
using Umbraco.Web.Common.Profiler;
using ConnectionStrings = Umbraco.Core.Configuration.Models.ConnectionStrings;
using CoreDebugSettings = Umbraco.Core.Configuration.Models.CoreDebugSettings;
using IHostingEnvironment = Umbraco.Core.Hosting.IHostingEnvironment;
using ILogger = Umbraco.Core.Logging.ILogger;
namespace Umbraco.Extensions
{
@@ -93,6 +95,28 @@ namespace Umbraco.Extensions
return services;
}
/// <summary>
/// Adds the Umbraco Back Core requirements
/// </summary>
/// <param name="services"></param>
/// <param name="webHostEnvironment"></param>
/// <param name="umbContainer"></param>
/// <param name="entryAssembly"></param>
/// <param name="appCaches"></param>
/// <param name="httpContextAccessor"></param>
/// <param name="loggingConfiguration"></param>
/// <param name="factory"></param>
/// <returns></returns>
public static IServiceCollection AddUmbracoCore(
this IServiceCollection services,
IWebHostEnvironment webHostEnvironment,
IRegister umbContainer,
Assembly entryAssembly,
AppCaches appCaches,
ILoggingConfiguration loggingConfiguration,
out IFactory factory)
=> services.AddUmbracoCore(webHostEnvironment, umbContainer, entryAssembly, appCaches, loggingConfiguration, GetCoreRuntime, out factory);
/// <summary>
/// Adds the Umbraco Configuration requirements
/// </summary>
@@ -184,6 +208,7 @@ namespace Umbraco.Extensions
Assembly.GetEntryAssembly(),
appCaches,
loggingConfig,
GetCoreRuntime,
out factory);
return services;
@@ -196,9 +221,10 @@ namespace Umbraco.Extensions
/// <param name="webHostEnvironment"></param>
/// <param name="umbContainer"></param>
/// <param name="entryAssembly"></param>
/// <param name="appCaches"></param>
/// <param name="requestCache"></param>
/// <param name="httpContextAccessor"></param>
/// <param name="loggingConfiguration"></param>
/// <param name="getRuntime">Delegate to create ana <see cref="IRuntime"/></param>
/// <param name="factory"></param>
/// <returns></returns>
public static IServiceCollection AddUmbracoCore(
@@ -206,34 +232,10 @@ namespace Umbraco.Extensions
IWebHostEnvironment webHostEnvironment,
IRegister umbContainer,
Assembly entryAssembly,
AppCaches appCaches,
AppCaches appCaches,
ILoggingConfiguration loggingConfiguration,
out IFactory factory)
=> services.AddUmbracoCore(webHostEnvironment, umbContainer, entryAssembly, appCaches, loggingConfiguration, GetCoreRuntime, out factory);
/// <summary>
/// Adds the Umbraco Back Core requirements
/// </summary>
/// <param name="services"></param>
/// <param name="webHostEnvironment"></param>
/// <param name="umbContainer"></param>
/// <param name="entryAssembly"></param>
/// <param name="appCaches"></param>
/// <param name="httpContextAccessor"></param>
/// <param name="loggingConfiguration"></param>
/// <param name="getRuntime">Delegate to create an <see cref="IRuntime"/></param>
/// <param name="factory"></param>
/// <returns></returns>
public static IServiceCollection AddUmbracoCore(
this IServiceCollection services,
IWebHostEnvironment webHostEnvironment,
IRegister umbContainer,
Assembly entryAssembly,
AppCaches appCaches,
ILoggingConfiguration loggingConfiguration,
// TODO: Yep that's extremely ugly
Func<Configs, GlobalSettings, ConnectionStrings, IUmbracoVersion, IIOHelper, Core.Logging.ILogger, IProfiler, Core.Hosting.IHostingEnvironment, IBackOfficeInfo, ITypeFinder, AppCaches, IDbProviderFactoryCreator, IRuntime> getRuntime,
//TODO: Yep that's extremely ugly
Func<Configs, GlobalSettings, ConnectionStrings, IUmbracoVersion, IIOHelper, ILogger, IProfiler, IHostingEnvironment, IBackOfficeInfo, ITypeFinder, AppCaches, IDbProviderFactoryCreator, IRuntime> getRuntime,
out IFactory factory)
{
if (services is null) throw new ArgumentNullException(nameof(services));
@@ -267,7 +269,6 @@ namespace Umbraco.Extensions
var typeFinderSettings = serviceProvider.GetService<IOptionsMonitor<TypeFinderSettings>>();
var dbProviderFactoryCreator = serviceProvider.GetRequiredService<IDbProviderFactoryCreator>();
var configs = serviceProvider.GetRequiredService<Configs>();
CreateCompositionRoot(services,
globalSettings,
@@ -279,7 +280,8 @@ namespace Umbraco.Extensions
var umbracoVersion = new UmbracoVersion();
var typeFinder = CreateTypeFinder(logger, profiler, webHostEnvironment, entryAssembly, typeFinderSettings);
var runtime = getRuntime(
var configs = serviceProvider.GetService<Configs>();
var coreRuntime = getRuntime(
configs,
globalSettings.CurrentValue,
connectionStrings.Value,
@@ -293,7 +295,14 @@ namespace Umbraco.Extensions
appCaches,
dbProviderFactoryCreator);
factory = runtime.Configure(container);
factory = coreRuntime.Configure(container);
services.Configure<HostingSettings>(hostingSettings =>
{
hostingSettings.Debug = false;
});
return services;
}