Skip to content

Document HostingStartup incompatibility with .NET Aspire integrations #4187

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 4, 2025

This PR addresses the issue where users are unable to configure .NET Aspire integrations when using HostingStartup because Aspire integrations require IHostApplicationBuilder instead of IWebHostBuilder.

Changes Made

New Troubleshooting Documentation

Added comprehensive documentation at docs/troubleshooting/hosting-startup-not-supported.md that:

  • Explains the incompatibility: HostingStartup only provides access to IWebHostBuilder, while .NET Aspire integrations require IHostApplicationBuilder
  • Documents symptoms: Compilation errors, runtime configuration issues, and missing telemetry/resilience features
  • Provides migration strategies: Four different approaches with complete code examples:
    1. Direct use of IHostApplicationBuilder (recommended)
    2. Creating configuration extensions
    3. Feature flags/configuration-based registration
    4. Dependency injection for plugin architecture

Updated Integration Documentation

Enhanced docs/fundamentals/integrations-overview.md with an important notice highlighting the HostingStartup limitation and linking to the migration guidance.

Table of Contents

Updated docs/toc.yml to include the new troubleshooting document in the appropriate section.

Example Migration Pattern

Before (HostingStartup - doesn't work):

public class MyDatabaseStartup : IHostingStartup
{
    public void Configure(IWebHostBuilder builder)
    {
        // This won't work with Aspire integrations
        builder.ConfigureServices(services => { ... });
    }
}

After (IHostApplicationBuilder - works with Aspire):

var builder = WebApplication.CreateBuilder(args);
builder.AddServiceDefaults();
builder.AddNpgsqlDbContext<MyDbContext>("postgres");

This documentation helps users maintain modularity while leveraging .NET Aspire's modern hosting patterns, observability features, and service discovery capabilities.

Fixes #3861.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.


Internal previews

📄 File 🔗 Preview link
docs/fundamentals/integrations-overview.md docs/fundamentals/integrations-overview
docs/toc.yml docs/toc
docs/troubleshooting/hosting-startup-not-supported.md docs/troubleshooting/hosting-startup-not-supported

@Copilot Copilot AI changed the title [WIP] When using Hosting startup I'm unable to configure most if any Aspire services Document HostingStartup incompatibility with .NET Aspire integrations Aug 4, 2025
@Copilot Copilot AI requested a review from IEvangelist August 4, 2025 20:47
Copilot finished work on behalf of IEvangelist August 4, 2025 20:47
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.

When using Hosting startup I'm unable to configure most if any Aspire services
2 participants