1212 /// </summary>
1313 internal static class DotNetConsoleDefaults
1414 {
15+ /// <summary>
16+ /// The command argument used to trigger dependency validation.
17+ /// </summary>
18+ internal const string CheckDependenciesCommand = "check-deps" ;
19+
20+ /// <summary>
21+ /// Determines if the given arguments represent a check-deps run.
22+ /// </summary>
23+ /// <param name="args">The command line arguments.</param>
24+ /// <returns>True if this is a check-deps run, false otherwise.</returns>
25+ public static bool IsCheckDependenciesRun ( string [ ] args )
26+ {
27+ return args . Length == 1 && string . Equals ( args [ 0 ] , CheckDependenciesCommand , StringComparison . OrdinalIgnoreCase ) ;
28+ }
29+
1530 /// <summary>
1631 /// Creates the console environment.
1732 /// </summary>
@@ -27,9 +42,17 @@ internal static DotNetConsoleEnvironment CreateConsoleEnvironment(string[] args)
2742 // The apps root directory is where the appsettings.json are located
2843 var appRootDirectory = AppContext . BaseDirectory ;
2944
45+ // Check if this is a check-deps run - if so, always use Development environment
46+ var isCheckDepsRun = IsCheckDependenciesRun ( args ) ;
47+
48+ // Default to Production for normal runs, matching ASP.NET Core behavior
49+ // For check-deps, always use Development to ensure appsettings.Development.json is loaded
50+ // Environment can be overridden via DOTNET_ENVIRONMENT or command line arguments
51+ var defaultEnvironment = isCheckDepsRun ? Environments . Development : Environments . Production ;
52+
3053 return new DotNetConsoleEnvironment
3154 {
32- EnvironmentName = configuration [ HostDefaults . EnvironmentKey ] ?? Environments . Production ,
55+ EnvironmentName = isCheckDepsRun ? Environments . Development : ( configuration [ HostDefaults . EnvironmentKey ] ?? defaultEnvironment ) ,
3356 ApplicationName = AppDomain . CurrentDomain . FriendlyName ,
3457 ContentRootPath = appRootDirectory ,
3558 ContentRootFileProvider = new PhysicalFileProvider ( appRootDirectory ) ,
0 commit comments