From 4391b542af7cac17067b7bc5e95a299b5717a67a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rodrigo=20Liberoff=20V=C3=A1zquez?= Date: Tue, 25 Jun 2024 14:12:37 +0200 Subject: [PATCH] - Added code to allow developers to add their own nominal settings on an `appsettings..json` file. These files are not committed to source control. --- src/AIHub/Program.cs | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/AIHub/Program.cs b/src/AIHub/Program.cs index faecbe3..af5111a 100644 --- a/src/AIHub/Program.cs +++ b/src/AIHub/Program.cs @@ -1,8 +1,17 @@ -using Azure; -using Azure.AI.ContentSafety; - var builder = WebApplication.CreateBuilder(args); +builder.Configuration.SetBasePath(Directory.GetCurrentDirectory()); + +/* Load Configuration */ +if (Debugger.IsAttached) +{ + builder.Configuration.AddJsonFile(@"appsettings.debug.json", optional: true, reloadOnChange: true); +} + +builder.Configuration.AddJsonFile($@"appsettings.{builder.Environment.EnvironmentName}.json", optional: true, reloadOnChange: true) + .AddJsonFile($@"appsettings.{Environment.UserName}.json", optional: true, reloadOnChange: true) + .AddEnvironmentVariables(); + // Add services to the container. builder.Services.AddControllersWithViews(); @@ -29,4 +38,4 @@ name: "default", pattern: "{controller=Home}/{action=Index}/{id?}"); -app.Run(); +await app.RunAsync();