From f185b549024c3c58f7829c6bb0d346f8ad6ae8b9 Mon Sep 17 00:00:00 2001 From: Tobias Wohlleben Date: Thu, 26 Sep 2024 10:21:01 +0200 Subject: [PATCH] umbau auf enviroment appsettings --- RBLNews.Maui/MauiProgram.cs | 12 ++++++-- RBLNews.Maui/Properties/launchSettings.json | 5 ++- RBLNews.Maui/RBLNews.Maui.csproj | 12 ++++---- RBLNews.Web/RBLNews.Web.csproj | 34 +++++++++++++-------- RBLNews.Web/appsettings.Development.json | 11 +++++++ RBLNews.Web/appsettings.Production.json | 12 ++++++++ RBLNews.Web/appsettings.Test.json | 12 ++++++++ RBLNews.Web/appsettings.json | 9 ++++++ 8 files changed, 86 insertions(+), 21 deletions(-) create mode 100644 RBLNews.Web/appsettings.Development.json create mode 100644 RBLNews.Web/appsettings.Production.json create mode 100644 RBLNews.Web/appsettings.Test.json create mode 100644 RBLNews.Web/appsettings.json diff --git a/RBLNews.Maui/MauiProgram.cs b/RBLNews.Maui/MauiProgram.cs index dda7c91..f3b70e9 100644 --- a/RBLNews.Maui/MauiProgram.cs +++ b/RBLNews.Maui/MauiProgram.cs @@ -1,4 +1,5 @@ -using CommunityToolkit.Maui; +using System.Reflection; +using CommunityToolkit.Maui; using CommunityToolkit.Maui.Markup; using Microsoft.Extensions.Configuration; @@ -40,9 +41,16 @@ namespace RBLNews.Maui builder.Logging.AddDebug(); #endif + Stream? appSettingFile = Assembly.GetExecutingAssembly().GetManifestResourceStream($"appsettings.json"); + if (appSettingFile != null) + { + IConfiguration configuration = new ConfigurationManager().AddJsonStream(appSettingFile).Build(); + builder.Configuration.AddConfiguration(configuration); + } + MauiApp app = builder.Build(); - AppSettingsModel? appSettings = app.Configuration.GetSection("Logging").Get(); + AppSettingsModel? appSettings = app.Configuration.GetSection("App").Get(); if (string.IsNullOrEmpty(appSettings?.BackendApiUrl)) { diff --git a/RBLNews.Maui/Properties/launchSettings.json b/RBLNews.Maui/Properties/launchSettings.json index edf8aad..84a49a4 100644 --- a/RBLNews.Maui/Properties/launchSettings.json +++ b/RBLNews.Maui/Properties/launchSettings.json @@ -2,7 +2,10 @@ "profiles": { "Windows Machine": { "commandName": "MsixPackage", - "nativeDebugging": false + "nativeDebugging": false, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } } } } \ No newline at end of file diff --git a/RBLNews.Maui/RBLNews.Maui.csproj b/RBLNews.Maui/RBLNews.Maui.csproj index 6f9f35c..bb9493c 100644 --- a/RBLNews.Maui/RBLNews.Maui.csproj +++ b/RBLNews.Maui/RBLNews.Maui.csproj @@ -80,16 +80,14 @@ - + PreserveNewest - + PreserveNewest - - PreserveNewest - - + + PreserveNewest @@ -98,6 +96,8 @@ + + diff --git a/RBLNews.Web/RBLNews.Web.csproj b/RBLNews.Web/RBLNews.Web.csproj index c36bac3..3963f4a 100644 --- a/RBLNews.Web/RBLNews.Web.csproj +++ b/RBLNews.Web/RBLNews.Web.csproj @@ -7,6 +7,28 @@ Linux + + + + + + + + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + PreserveNewest + + + @@ -19,18 +41,6 @@ Always - - appsettings.Development.json - - - appsettings.json - - - appsettings.Production.json - - - appsettings.Test.json - diff --git a/RBLNews.Web/appsettings.Development.json b/RBLNews.Web/appsettings.Development.json new file mode 100644 index 0000000..7a608cd --- /dev/null +++ b/RBLNews.Web/appsettings.Development.json @@ -0,0 +1,11 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "App": { + "BackendApiUrl": "https://localhost:5147" + } +} diff --git a/RBLNews.Web/appsettings.Production.json b/RBLNews.Web/appsettings.Production.json new file mode 100644 index 0000000..0c2c7dc --- /dev/null +++ b/RBLNews.Web/appsettings.Production.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "App": { + "BackendApiUrl": "https://rblnews.de" + } +} diff --git a/RBLNews.Web/appsettings.Test.json b/RBLNews.Web/appsettings.Test.json new file mode 100644 index 0000000..8ceaf0e --- /dev/null +++ b/RBLNews.Web/appsettings.Test.json @@ -0,0 +1,12 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*", + "App": { + "BackendApiUrl": "https://rbl.wohlleben.dev" + } +} diff --git a/RBLNews.Web/appsettings.json b/RBLNews.Web/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/RBLNews.Web/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +}