config: a little dynamic config based on environmnet
All checks were successful
Test if Server can be built / build-server (push) Successful in 23s

This commit is contained in:
Timothy Schenk 2023-08-14 21:45:00 +02:00
parent f802dcf2a3
commit d44d072823
3 changed files with 9 additions and 2 deletions

View file

@ -3,6 +3,7 @@ using System.Net;
using System.Reflection; using System.Reflection;
using MassTransit; using MassTransit;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting; using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
@ -10,6 +11,12 @@ using Server.DB;
using Server.Services; using Server.Services;
var builder = Host.CreateApplicationBuilder(); var builder = Host.CreateApplicationBuilder();
#if DEBUG
builder.Environment.EnvironmentName = "Development";
#endif
builder.Configuration.AddJsonFile("settings.json", true, true)
.AddJsonFile($"settings.{builder.Environment.EnvironmentName}.json", optional: true)
.AddEnvironmentVariables().Build();
builder.Services.AddLogging(); builder.Services.AddLogging();
builder.Logging.AddFile("Logs/Server-{Date}.log", LogLevel.Trace); builder.Logging.AddFile("Logs/Server-{Date}.log", LogLevel.Trace);
builder.Logging.AddFile("Logs/Server-{Date}.json.log", LogLevel.Trace, isJson: true); builder.Logging.AddFile("Logs/Server-{Date}.json.log", LogLevel.Trace, isJson: true);

View file

@ -69,8 +69,8 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Update="settings.json"> <Content Include="settings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None> </Content>
</ItemGroup> </ItemGroup>
</Project> </Project>