mirror of
https://github.com/AlexMacocian/ServerManagementUtils.git
synced 2026-07-15 15:19:58 +00:00
32 lines
883 B
C#
32 lines
883 B
C#
using System.Core.Extensions;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace Robin.Configuration;
|
|
|
|
public static class BuilderExtensions
|
|
{
|
|
public static IHostApplicationBuilder AddEnvironmentVariables(
|
|
this IHostApplicationBuilder builder
|
|
)
|
|
{
|
|
#if DEBUG
|
|
DotNetEnv.Env.Load(Path.Combine(AppContext.BaseDirectory, ".env"));
|
|
#endif
|
|
builder.ThrowIfNull().Configuration.AddEnvironmentVariables();
|
|
return builder;
|
|
}
|
|
|
|
public static IHostApplicationBuilder AddAppsettings(this IHostApplicationBuilder builder)
|
|
{
|
|
builder
|
|
.ThrowIfNull()
|
|
.Configuration.AddJsonFile(
|
|
path: Path.Combine(AppContext.BaseDirectory, "appsettings.json"),
|
|
optional: false,
|
|
reloadOnChange: true
|
|
);
|
|
return builder;
|
|
}
|
|
}
|