diff --git a/src/Umbraco.Tests.Integration/RuntimeTests.cs b/src/Umbraco.Tests.Integration/RuntimeTests.cs
index 2974a01669..5968ee89fb 100644
--- a/src/Umbraco.Tests.Integration/RuntimeTests.cs
+++ b/src/Umbraco.Tests.Integration/RuntimeTests.cs
@@ -97,7 +97,7 @@ namespace Umbraco.Tests.Integration
// Add it!
services.AddUmbracoConfiguration(hostContext.Configuration);
- services.AddUmbracoCore(webHostEnvironment, umbracoContainer, GetType().Assembly);
+ services.AddUmbracoCore(webHostEnvironment, umbracoContainer, GetType().Assembly, out _);
});
var host = await hostBuilder.StartAsync();
@@ -136,7 +136,7 @@ namespace Umbraco.Tests.Integration
// Add it!
services.AddUmbracoConfiguration(hostContext.Configuration);
- services.AddUmbracoCore(webHostEnvironment, umbracoContainer, GetType().Assembly);
+ services.AddUmbracoCore(webHostEnvironment, umbracoContainer, GetType().Assembly, out _);
});
var host = await hostBuilder.StartAsync();
diff --git a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
index 43504e908a..d822d687d9 100644
--- a/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
+++ b/src/Umbraco.Tests.Integration/Testing/UmbracoIntegrationTest.cs
@@ -118,7 +118,7 @@ namespace Umbraco.Tests.Integration.Testing
// Add it!
services.AddUmbracoConfiguration(hostContext.Configuration);
- services.AddUmbracoCore(webHostEnvironment, umbracoContainer, GetType().Assembly);
+ services.AddUmbracoCore(webHostEnvironment, umbracoContainer, GetType().Assembly, out _);
});
var host = await hostBuilder.StartAsync();
diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
index a0dd1f8e63..41581523bb 100644
--- a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
+++ b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
@@ -51,13 +51,25 @@ namespace Umbraco.Web.Common.Extensions
///
///
public static IServiceCollection AddUmbracoCore(this IServiceCollection services, IWebHostEnvironment webHostEnvironment)
+ {
+ return services.AddUmbracoCore(webHostEnvironment,out _);
+ }
+
+ ///
+ /// Adds the Umbraco Back Core requirements
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IServiceCollection AddUmbracoCore(this IServiceCollection services, IWebHostEnvironment webHostEnvironment, out IFactory factory)
{
if (!UmbracoServiceProviderFactory.IsActive)
throw new InvalidOperationException("Ensure to add UseUmbraco() in your Program.cs after ConfigureWebHostDefaults to enable Umbraco's service provider factory");
var umbContainer = UmbracoServiceProviderFactory.UmbracoContainer;
- return services.AddUmbracoCore(webHostEnvironment, umbContainer, Assembly.GetEntryAssembly());
+ return services.AddUmbracoCore(webHostEnvironment, umbContainer, Assembly.GetEntryAssembly(), out factory);
}
///
@@ -67,8 +79,9 @@ namespace Umbraco.Web.Common.Extensions
///
///
///
+ ///
///
- public static IServiceCollection AddUmbracoCore(this IServiceCollection services, IWebHostEnvironment webHostEnvironment, IRegister umbContainer, Assembly entryAssembly)
+ public static IServiceCollection AddUmbracoCore(this IServiceCollection services, IWebHostEnvironment webHostEnvironment, IRegister umbContainer, Assembly entryAssembly, out IFactory factory)
{
if (services is null) throw new ArgumentNullException(nameof(services));
var container = umbContainer;
@@ -98,7 +111,7 @@ namespace Umbraco.Web.Common.Extensions
backOfficeInfo,
typeFinder);
- var factory = coreRuntime.Configure(container);
+ factory = coreRuntime.Configure(container);
return services;
}
diff --git a/src/Umbraco.Web.UI.NetCore/Startup.cs b/src/Umbraco.Web.UI.NetCore/Startup.cs
index 3906f1c8e9..da6e45086f 100644
--- a/src/Umbraco.Web.UI.NetCore/Startup.cs
+++ b/src/Umbraco.Web.UI.NetCore/Startup.cs
@@ -14,11 +14,13 @@ using Umbraco.Composing;
using Umbraco.Core;
using Umbraco.Core.Configuration;
using Umbraco.Core.IO;
+using Umbraco.Core.Logging;
using Umbraco.Web.BackOffice.AspNetCore;
using Umbraco.Web.Common.AspNetCore;
using Umbraco.Web.Common.Extensions;
using Umbraco.Web.Common.Runtime.Profiler;
using Umbraco.Web.Website.AspNetCore;
+using IHostingEnvironment = Umbraco.Core.Hosting.IHostingEnvironment;
namespace Umbraco.Web.UI.BackOffice
@@ -47,7 +49,7 @@ namespace Umbraco.Web.UI.BackOffice
public void ConfigureServices(IServiceCollection services)
{
services.AddUmbracoConfiguration(_config);
- services.AddUmbracoCore(_webHostEnvironment);
+ services.AddUmbracoCore(_webHostEnvironment, out var factory);
services.AddUmbracoWebsite();
services.AddMvc();
@@ -55,6 +57,17 @@ namespace Umbraco.Web.UI.BackOffice
{
options.ShouldProfile = request => false; // WebProfiler determine and start profiling. We should not use the MiniProfilerMiddleware to also profile
});
+
+ //Finally initialize Current
+ Current.Initialize(
+ factory.GetInstance (),
+ factory.GetInstance(),
+ factory.GetInstance(),
+ factory.GetInstance(),
+ factory.GetInstance(),
+ factory.GetInstance()
+ );
+
}
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.