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

@@ -63,9 +63,9 @@ namespace Umbraco.Core.Composing
public IRuntimeState RuntimeState { get; }
// TODO: remove this once no longer required for functionality in Umbraco.Web.
/// <summary>
/// Gets the configurations.
/// </summary>
/// <summary>
/// Gets the configurations.
/// </summary>
public Configs Configs { get; }
#endregion

View File

@@ -17,41 +17,43 @@ namespace Umbraco.Tests.Integration.TestServerTest
/// </summary>
/// <param name="builder"></param>
/// <returns></returns>
public static IUmbracoBuilder WithTestCore(this IUmbracoBuilder builder, TestHelper testHelper, LightInjectContainer container,
public static IUmbracoBuilder WithTestCore(this IUmbracoBuilder builder, TestHelper testHelper,
LightInjectContainer container,
Action<CoreRuntime, RuntimeEssentialsEventArgs> dbInstallEventHandler)
{
return builder.AddWith(nameof(global::Umbraco.Web.Common.Builder.UmbracoBuilderExtensions.WithCore),
() =>
{
builder.Services.AddUmbracoCore(
builder.WebHostEnvironment,
container,
typeof(UmbracoBuilderExtensions).Assembly,
AppCaches.NoCache, // Disable caches in integration tests
testHelper.GetLoggingConfiguration(),
// TODO: Yep that's extremely ugly
(configs, globalSettings, connectionStrings, umbVersion, ioHelper, logger, profiler, hostingEnv, backOfficeInfo, typeFinder, appCaches, dbProviderFactoryCreator) =>
{
var runtime = UmbracoIntegrationTest.CreateTestRuntime(
configs,
globalSettings,
connectionStrings,
umbVersion,
ioHelper,
logger,
profiler,
hostingEnv,
backOfficeInfo,
typeFinder,
appCaches,
dbProviderFactoryCreator,
testHelper.MainDom, // SimpleMainDom
dbInstallEventHandler); // DB Installation event handler
() =>
{
builder.Services.AddUmbracoCore(
builder.WebHostEnvironment,
container,
typeof(UmbracoBuilderExtensions).Assembly,
AppCaches.NoCache, // Disable caches in integration tests
testHelper.GetLoggingConfiguration(),
// TODO: Yep that's extremely ugly
(configs, globalSettings, connectionStrings, umbVersion, ioHelper, logger, profiler, hostingEnv,
backOfficeInfo, typeFinder, appCaches, dbProviderFactoryCreator) =>
{
var runtime = UmbracoIntegrationTest.CreateTestRuntime(
configs,
globalSettings,
connectionStrings,
umbVersion,
ioHelper,
logger,
profiler,
hostingEnv,
backOfficeInfo,
typeFinder,
appCaches,
dbProviderFactoryCreator,
testHelper.MainDom, // SimpleMainDom
dbInstallEventHandler); // DB Installation event handler
return runtime;
},
out _);
});
return runtime;
},
out _);
});
}
}
}

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;
}

View File

@@ -34,6 +34,7 @@ namespace Umbraco.Web.UI.NetCore
{
var umbracoBuilder = services.AddUmbraco(_env, _config);
umbracoBuilder.BuildWithAllBackOfficeComponents();
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.

View File

@@ -17,7 +17,7 @@
<ProjectReference Include="..\Umbraco.Web.BackOffice\Umbraco.Web.BackOffice.csproj" />
<ProjectReference Include="..\Umbraco.Web.Common\Umbraco.Web.Common.csproj" />
<ProjectReference Include="..\Umbraco.Web.Website\Umbraco.Web.Website.csproj" />
<ProjectReference Include="..\Umbraco.Persistance.SqlCe\Umbraco.Persistance.SqlCe.csproj" Condition="'$(OS)' == 'Windows_NT'" />
<ProjectReference Include="..\Umbraco.Persistance.SqlCe\Umbraco.Persistance.SqlCe.csproj" Condition="'$(OS)' == 'Windows_NT'" />
</ItemGroup>
<ItemGroup>