Make appsettings.json optional; support appsettings.local.json override
App no longer crashes on startup when appsettings.json is absent (e.g. fresh clone). Configuration is loaded from appsettings.json if present, then overridden by appsettings.local.json if that exists. Both files are gitignored to keep secrets out of the repo. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -7,6 +7,7 @@ obj/
|
||||
|
||||
# Config with secrets — never commit
|
||||
EbayListingTool/appsettings.json
|
||||
EbayListingTool/appsettings.local.json
|
||||
|
||||
# Rider / JetBrains
|
||||
.idea/
|
||||
|
||||
@@ -22,7 +22,8 @@ public partial class App : Application
|
||||
|
||||
Configuration = new ConfigurationBuilder()
|
||||
.SetBasePath(AppContext.BaseDirectory)
|
||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: false)
|
||||
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: false)
|
||||
.AddJsonFile("appsettings.local.json", optional: true, reloadOnChange: false)
|
||||
.Build();
|
||||
|
||||
base.OnStartup(e);
|
||||
|
||||
Reference in New Issue
Block a user