Skip to content

Log exception when app fails to start in CLI#3853

Merged
martincostello merged 3 commits intodomaindrivendev:masterfrom
ODukhno:old/improveLogging
Mar 19, 2026
Merged

Log exception when app fails to start in CLI#3853
martincostello merged 3 commits intodomaindrivendev:masterfrom
ODukhno:old/improveLogging

Conversation

@ODukhno
Copy link
Contributor

@ODukhno ODukhno commented Mar 18, 2026

There is a misleading logging that happens under the following conditions:

  1. We use .NET app with minimal hosting model
  2. We use dotnet tool in our csproj file like this:
  1. We introduce an issue in our Program.cs, so the application just cannot start up.

We receive an error like the following:

AI.Crawl.Client -> C:\Users\oldukhno\work\Invictus\artifacts\bin\AI.Crawl.Client\debug_net10.0\AI.Crawl.Client.dll
AI.Search.Services.Internal -> C:\Users\oldukhno\work\Invictus\artifacts\bin\AI.Search.Services.Internal\debug_net10.0\AI.Search.Services.Internal.dll
AI.Search.Services.Agents.Foundry -> C:\Users\oldukhno\work\Invictus\artifacts\bin\AI.Search.Services.Agents.Foundry\debug_net10.0\AI.Search.Services.Agents.Foundry.dll
AI.Search.Host -> C:\Users\oldukhno\work\Invictus\artifacts\bin\AI.Search.Host\debug\AI.Search.Host.dll
Unhandled exception. System.InvalidOperationException: A type named 'StartupDevelopment' or 'Startup' could not be found in assembly 'AI.Search.Host'.
at Microsoft.AspNetCore.Hosting.StartupLoader.FindStartupType(String startupAssemblyName, String environmentName)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.ScanAssemblyAndRegisterStartup(HostBuilderContext context, IServiceCollection services, WebHostBuilderContext webhostContext, WebHostOptions webHostOptions)
at Microsoft.AspNetCore.Hosting.GenericWebHostBuilder.<.ctor>b__4_2(HostBuilderContext context, IServiceCollection services)
at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Swashbuckle.AspNetCore.Cli.Program.GetServiceProvider(Assembly startupAssembly) in //src/Swashbuckle.AspNetCore.Cli/Program.cs:line 257
at Swashbuckle.AspNetCore.Cli.Program.SetupAndRetrieveSwaggerProviderAndOptions(IDictionary2 namedArgs, ISwaggerProvider& swaggerProvider, IOptions1& swaggerOptions) in /
/src/Swashbuckle.AspNetCore.Cli/Program.cs:line 195
at Swashbuckle.AspNetCore.Cli.Program.<>c.

b__1_5(IDictionary2 namedArgs) in /_/src/Swashbuckle.AspNetCore.Cli/Program.cs:line 65 at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable1 args) in //src/Swashbuckle.AspNetCore.Cli/CommandRunner.cs:line 56
at Swashbuckle.AspNetCore.Cli.CommandRunner.Run(IEnumerable`1 args) in /
/src/Swashbuckle.AspNetCore.Cli/CommandRunner.cs:line 47
at Swashbuckle.AspNetCore.Cli.Program.Main(String[] args) in /_/src/Swashbuckle.AspNetCore.Cli/Program.cs:line 189
C:\Users\oldukhno\work\Invictus\src\hosts\AI.Search.Host\AI.Search.Host.csproj(72,5): error MSB3073:

The command "dotnet swagger tofile --output "C:\Users\oldukhno\work\Invictus\src\hosts\AI.Search.Host/../../clients/AI.Search.Client/swagger.json" "C:\Users\oldukhno\work\Invictus\artifacts\bin\AI.Search.Host\debug\AI.Search.Host.dll" v1" exited with code -532462766.

This is misleading and hiding the actual issue. We had better output the error message to stderr instead just swallowing it.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.95%. Comparing base (c0efe07) to head (51458e2).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #3853   +/-   ##
=======================================
  Coverage   94.95%   94.95%           
=======================================
  Files         111      111           
  Lines        3886     3886           
  Branches      783      783           
=======================================
  Hits         3690     3690           
  Misses        196      196           
Flag Coverage Δ
Linux 94.95% <ø> (ø)
Windows 94.95% <ø> (ø)
macOS 94.95% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@martincostello martincostello changed the title Misleading error : Do not swallow exception when app cannot startup Log exception when app fails to start in CLI Mar 19, 2026
@martincostello martincostello added this to the v10.1.6 milestone Mar 19, 2026
Rename `exception` to `ex`.
@martincostello martincostello enabled auto-merge (squash) March 19, 2026 10:16
@martincostello martincostello merged commit 40d1995 into domaindrivendev:master Mar 19, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants