using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Umbraco.Cms.Core.DependencyInjection;
using Umbraco.Cms.Web.Common.Hosting;
// ReSharper disable once CheckNamespace
namespace Microsoft.Extensions.Hosting;
///
/// Umbraco specific extensions for the interface.
///
public static class HostBuilderExtensions
{
///
/// Configures an existing with defaults for an Umbraco application.
///
public static IHostBuilder ConfigureUmbracoDefaults(this IHostBuilder builder)
{
#if DEBUG
builder.ConfigureAppConfiguration(config
=> config.AddJsonFile(
"appsettings.Local.json",
true,
true));
#endif
builder.ConfigureLogging(x => x.ClearProviders());
return new UmbracoHostBuilderDecorator(builder, OnHostBuilt);
}
// Runs before any IHostedService starts (including generic web host).
private static void OnHostBuilt(IHost host) =>
StaticServiceProvider.Instance = host.Services;
}