Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/Host/FSH.Starter.DbMigrator/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,18 @@
await Console.Out.WriteLineAsync(MigratorCommand.HelpText).ConfigureAwait(false);
return 0;
}

var builder = Host.CreateApplicationBuilder(args);

// In local development (dotnet run), the working directory is the project folder,
// but appsettings.json is linked and copied to the output directory.
// We explicitly load it from AppContext.BaseDirectory so IdentityModule's JwtOptions validate.
builder.Configuration.AddJsonFile(Path.Combine(AppContext.BaseDirectory, "appsettings.json"), optional: true);
builder.Configuration.AddJsonFile(Path.Combine(AppContext.BaseDirectory, $"appsettings.{builder.Environment.EnvironmentName}.json"), optional: true);

// Re-add environment variables and command line args so they maintain priority over the manually added JSON files.
builder.Configuration.AddEnvironmentVariables();
builder.Configuration.AddCommandLine(args);

// Fail-fast before option-validation runs at host build time: if the operator
// forgot to set DatabaseOptions__ConnectionString, give them a single clear
// line they'll actually read rather than a validation exception stack trace.
Expand Down
Loading