Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

Upgrade Aspire AI Chat Demo to Aspire 13

Plan:

  • Explore repository structure and understand current Aspire version (9.5.0)
  • Research Aspire 13 requirements and changes
  • Verify current build works with .NET 10
  • Update Aspire.AppHost.Sdk from 9.5.0 to 13.0.0
  • Update all Aspire.Hosting.* packages to 13.0.0
  • Update Aspire.Hosting.NodeJs to Aspire.Hosting.JavaScript 13.0.0 (renamed in v13)
  • Update Aspire integration packages to appropriate versions
  • Update Microsoft.Extensions.* packages to 10.0.0
  • Update CommunityToolkit.Aspire packages to 9.9.0
  • Update API usage: AddNpmApp → AddJavaScriptApp → AddViteApp
  • Test build after updates - successful!
  • Use AddViteApp with auto port configuration
  • Use YARP PublishWithStaticFiles pattern
  • Remove deprecated CommunityToolkit.Aspire.Hosting.NodeJS.Extensions
  • Remove Dockerfile (no longer needed)
  • Use WithReference for chatapi (service discovery)
  • Update vite proxy to use CHATAPI_HTTPS/CHATAPI_HTTP env vars
  • Add WithExplicitStart to YARP
  • Simplify YARP route configuration
  • Use Aspire.AppHost.Sdk directly in project file
  • Remove Aspire.Hosting.AppHost package reference
  • Resolve target once in vite.config.ts
  • Remove manual port resolution from vite.config.ts
  • Update GitHub Actions to use .NET 10
  • Change from aspire publish to aspire do build
  • Implement dynamic Docker image discovery with proper sorting and matching
  • Add debug logging to aspire do build
  • Run code review and address feedback
  • Run security checks
  • Complete upgrade

Summary

Successfully upgraded the Aspire AI Chat Demo from Aspire 9.5 to Aspire 13.0 with modern best practices including simplified project configuration, proper service discovery, HTTPS support, cleaner Vite configuration, and updated CI/CD pipeline with robust Docker image handling and debug logging.

Changes Made

1. Package Version Updates:

  • Aspire.AppHost.Sdk: 9.5.0 → 13.0.0 (now used directly as project SDK)
  • Aspire.Hosting.Docker: 9.5.0-preview → 13.0.0-preview.1.25560.3
  • Aspire.Hosting.OpenAI: 9.5.0-preview → 13.0.0
  • Aspire.Hosting.PostgreSQL: 9.5.0 → 13.0.0
  • Aspire.Hosting.Redis: 9.5.0 → 13.0.0
  • Aspire.Hosting.NodeJsAspire.Hosting.JavaScript: 13.0.0 (renamed in v13)
  • Aspire.Hosting.Yarp: 9.5.0-preview → 13.0.0
  • Aspire.Npgsql.EntityFrameworkCore.PostgreSQL: 9.5.0 → 9.5.2 (13.0.0 not yet available)
  • Aspire.OpenAI: 9.5.0-preview → 13.0.0-preview.1.25560.3
  • Aspire.StackExchange.Redis: 9.5.0 → 13.0.0
  • Microsoft.Extensions.Http.Resilience: 9.5.0 → 10.0.0
  • Microsoft.Extensions.ServiceDiscovery: 9.5.0 → 10.0.0
  • CommunityToolkit.Aspire.Hosting.Ollama: 9.4.0 → 9.9.0
  • Removed: CommunityToolkit.Aspire.Hosting.NodeJS.Extensions (deprecated)
  • Removed: Aspire.Hosting.AppHost package reference (now included in SDK)

2. Project File Modernization:

<!-- Before -->
<Project Sdk="Microsoft.NET.Sdk">
  <Sdk Name="Aspire.AppHost.Sdk" Version="13.0.0" />
  <ItemGroup>
    <PackageReference Include="Aspire.Hosting.AppHost" Version="13.0.0" />
  </ItemGroup>
</Project>

<!-- After -->
<Project Sdk="Aspire.AppHost.Sdk/13.0.0">
  <!-- Aspire.Hosting.AppHost no longer needed -->
</Project>

3. Modern Vite App Hosting:

  • Replaced AddJavaScriptApp() with AddViteApp() for Vite-specific support
  • Removed WithOtlpExporter() - no longer needed
  • Used WithReference(chatapi) for proper service discovery
  • Port is now auto-configured by Aspire

4. Vite Configuration Improvements:

  • Resolved target once instead of duplicating
  • Removed manual port resolution (handled by Aspire)
  • Removed unused ServerOptions import

5. YARP Configuration:

  • Replaced WithDockerfile() with PublishWithStaticFiles(frontend)
  • Simplified route: c.AddRoute("/api/{**catch-all}", chatapi) - HTTPS now works!
  • Added WithExplicitStart() for controlled startup

6. GitHub Actions CI/CD Updates:

# Before
- dotnet-version: '9.x'
- run: aspire publish -p docker-compose -o artifacts

# After
- dotnet-version: '10.x'
- run: aspire do build --log-level debug
  • Updated to .NET 10
  • Changed from aspire publish to aspire do build --log-level debug for container image building with verbose logging
  • Implemented robust Docker image discovery:
    • Sorts by creation date (sort -r) to get most recent images
    • Uses specific pattern matching to avoid false positives
    • Proper error handling if images not found

7. Cleanup:

  • Removed chatui/Dockerfile - auto-generated on publish now
  • Removed deprecated CommunityToolkit NodeJS Extensions package
  • Removed redundant Aspire.Hosting.AppHost package reference

Benefits:

  • ✅ Cleaner project file using SDK directly
  • ✅ Proper service discovery with automatic environment variable injection
  • ✅ HTTPS support now working
  • ✅ Simplified configuration without manual endpoint/port management
  • ✅ DRY vite.config.ts with no duplication
  • ✅ Better development and production parity
  • ✅ Modern CI/CD pipeline with .NET 10 and aspire do build
  • ✅ Debug logging enabled for better troubleshooting
  • ✅ Robust Docker image discovery with proper sorting and specific pattern matching
  • ✅ Consistently selects most recently built images

Security Summary

  • ✅ CodeQL security scan: No vulnerabilities found
  • ✅ Dependency security check: No known vulnerabilities in any packages
  • ✅ Build successful with all updated packages
  • ✅ Code review feedback addressed
Original prompt

Update this to aspire 13! https://aspire.dev/whats-new/aspire-13/


💡 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.

Copilot AI changed the title [WIP] Update documentation for Aspire 13 Upgrade to Aspire 13 Nov 24, 2025
Copilot AI requested a review from davidfowl November 24, 2025 09:09
@davidfowl
Copy link
Owner

@copilot We should be able to use AddViteApp which will auto configure the vite port, so we can remove the manual port. We should be able to remove the docker files completely.

See an example of hosting a vite app in yarp on publish.

var frontend = builder.AddViteApp("frontend", "./frontend");

builder.AddYarp("app")
       .WithExternalHttpEndpoints()
       .PublishWithStaticFiles(frontend);

Copy link
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot We should be able to use AddViteApp which will auto configure the vite port, so we can remove the manual port. We should be able to remove the docker files completely.

See an example of host...

Done in commit f046730. Changes made:

  • Replaced AddJavaScriptApp with AddViteApp (auto-configures Vite port)
  • Updated YARP to use PublishWithStaticFiles(frontend) pattern
  • Removed manual port configuration
  • Removed deprecated CommunityToolkit.Aspire.Hosting.NodeJS.Extensions package
  • Removed chatui/Dockerfile (now auto-generated on publish)

@davidfowl
Copy link
Owner

@copilot More changes, we can make. Remove WithOtlpExporter from AddViteApp. We should be able to use WithReference(chatapi) for the vite app. We need to update the proxy url in vite.config to be process.env.CHATAPI_HTTPS || process.env.CHATAPI_HTTP intead of process.env.BACKEND_URL.

Add the WithExplicitStart back to yarp and use:

c.AddRoute("/api/{**catch-all}", chatapi);

As https now works!

Copy link
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot More changes, we can make. Remove WithOtlpExporter from AddViteApp. We should be able to use WithReference(chatapi) for the vite app. We need to update the proxy url in vite.config to be pro...

Done in commit 1d665b9. Changes made:

  • Removed WithOtlpExporter() from AddViteApp
  • Used WithReference(chatapi) for service discovery
  • Updated vite.config.ts proxy to use process.env.CHATAPI_HTTPS || process.env.CHATAPI_HTTP
  • Added WithExplicitStart() back to YARP
  • Simplified route to c.AddRoute("/api/{**catch-all}", chatapi)

@davidfowl
Copy link
Owner

@copilot - We can resolve the target once in vite.config.ts instead of duplicating it

  • Lets go further and use the aspire sdk in the project file and remove

Copy link
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot - We can resolve the target once in vite.config.ts instead of duplicating it

  • Lets go further and use the aspire sdk in the project file and remove ...

Done in commit e6b61e5. Changes made:

  • Resolved target once in vite.config.ts (removed duplication)
  • Used Aspire.AppHost.Sdk/13.0.0 directly as project SDK
  • Removed Aspire.Hosting.AppHost package reference (now included in SDK)
  • Removed manual port resolution from vite.config.ts
  • Removed unused ServerOptions import

@davidfowl
Copy link
Owner

@copilot We want to update the github action to use .NET 10 and to change aspire publish to aspire do build. This will build container images. The big problem is that we don't have a way of resolving what was build, so the tag and push logic needs to be a bit more complex. We need to query docker images and then find the latest chat and chatui imge and push them to the registry

Copy link
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot We want to update the github action to use .NET 10 and to change aspire publish to aspire do build. This will build container images. The big problem is that we don't have a way of resolv...

Done in commits 244838e and 092fab6. Changes made:

  • Updated to .NET 10 (from .NET 9)
  • Changed from aspire publish -p docker-compose -o artifacts to aspire do build
  • Implemented Docker image discovery using docker images with:
    • Sorting by creation date (sort -r) to select most recently built images
    • Specific pattern matching to avoid false positives
    • Proper error handling if images not found
  • Query finds the latest chatapi and chatui images dynamically and tags/pushes them to the registry

@davidfowl
Copy link
Owner

@copilot use --log-level debug for aspire do build

Copy link
Contributor Author

Copilot AI commented Nov 24, 2025

@copilot use --log-level debug for aspire do build

Done in commit 4a7f251. Added --log-level debug flag to aspire do build command for verbose logging during the build process.

@davidfowl davidfowl marked this pull request as ready for review November 25, 2025 08:37
@davidfowl davidfowl merged commit 32302fc into main Nov 25, 2025
1 check 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.

2 participants