Enhance configuration loading: skip example config in development and update launch settings for local debugging

This commit is contained in:
troogs
2026-09-14 15:45:24 +02:00
parent 8df4abc8a3
commit fdd7ea5a40
5 changed files with 12 additions and 6 deletions
+4 -2
View File
@@ -72,8 +72,10 @@ namespace FoodsharingSiegen.Server
// Check if the directory exists
if (Directory.Exists(configDir))
{
// Get all JSON files that start with "appsettings" in the directory and its subdirectories
var configFiles = Directory.EnumerateFiles(configDir, "appsettings*.json", SearchOption.AllDirectories);
// In local development, skip the template-only example config so a debug override
// such as ASPNETCORE_URLS can take effect without changing the container image setup.
var configFiles = Directory.EnumerateFiles(configDir, "appsettings*.json", SearchOption.AllDirectories)
.Where(file => !builder.Environment.IsDevelopment() || !Path.GetFileName(file).Equals("appsettings.example.json", StringComparison.OrdinalIgnoreCase));
// Add each file to the configuration
foreach (var file in configFiles) builder.Configuration.AddJsonFile(file, true, true);
@@ -0,0 +1 @@
{"version":3,"sourceRoot":"","sources":["AuditView.razor.scss"],"names":[],"mappings":"AAAA;EACE","file":"AuditView.razor.css"}
+2 -1
View File
@@ -14,7 +14,8 @@ using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.LoadAppSettings();
builder.WebHost.UseUrls("http://+:8700");
// Keep the app default binding in config for Docker/container deployment.
// Local debugging can override it via ASPNETCORE_URLS in launchSettings.
// Add services to the container.
builder.Services.AddRazorPages();
@@ -12,10 +12,11 @@
"commandName": "Project",
"dotnetRunMessages": true,
"launchBrowser": true,
"launchUrl": "http://localhost:56000/",
"applicationUrl": "http://localhost:56000",
"launchUrl": "http://localhost:5010/",
"applicationUrl": "http://localhost:5010",
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
"ASPNETCORE_ENVIRONMENT": "Development",
"ASPNETCORE_URLS": "http://localhost:5010"
}
},
"IIS Express": {
@@ -0,0 +1 @@
{"version":3,"sourceRoot":"","sources":["NavMenu.razor.scss"],"names":[],"mappings":"AAEA;EACI;;AAEA;EAHJ;IAIQ;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;EACA;;AAEA;EATJ;IAUQ;IACA;;;;AAKZ;EACI;EACA;EACA;EACA;;;AAGJ;EACI;EACA;;;AAGA;EACI;;;AAGJ;EACI;;;AAGJ;EACI;EACA;EACA;EACA;EACA;EACA;;;AAGR;EACI;EACA;;;AAGJ;EACI;EACA","file":"NavMenu.razor.css"}