Skip to content

.NET: fix(aspire-devui): ship Microsoft.Agents.AI.DevUI as a transitive dependency#5908

Open
jluocsa wants to merge 1 commit into
microsoft:mainfrom
jluocsa:fix/aspire-devui-bundle-frontend-5779
Open

.NET: fix(aspire-devui): ship Microsoft.Agents.AI.DevUI as a transitive dependency#5908
jluocsa wants to merge 1 commit into
microsoft:mainfrom
jluocsa:fix/aspire-devui-bundle-frontend-5779

Conversation

@jluocsa
Copy link
Copy Markdown

@jluocsa jluocsa commented May 17, 2026

Motivation and Context

Aspire.Hosting.AgentFramework.DevUI starts an in-process Kestrel aggregator that serves the DevUI frontend from embedded resources in the Microsoft.Agents.AI.DevUI assembly. The aggregator discovers that assembly at runtime via:

Assembly.Load("Microsoft.Agents.AI.DevUI")

in DevUIAggregatorHostedService.LoadFrontendResources.

Until now, Microsoft.Agents.AI.DevUI was not referenced by Aspire.Hosting.AgentFramework.DevUI.csproj. Users who followed the README's installation instructions (dotnet add package Aspire.Hosting.AgentFramework.DevUI) ended up with the aggregator but not the frontend assembly. Assembly.Load then failed silently (debug-level log), no backend served /devui/, and GET /devui/ returned HTTP 404 — exactly the failure mode reported in #5779.

The only place this worked was the DevUIAspireIntegration sample, which carries a second explicit ProjectReference to Microsoft.Agents.AI.DevUI. The reporter (@hansmbakker) independently arrived at the same workaround and asked for the dependency to be automatic.

Description

Make Microsoft.Agents.AI.DevUI a first-class dependency of Aspire.Hosting.AgentFramework.DevUI so the integration works out of the box from a single dotnet add package invocation:

  • dotnet/src/Aspire.Hosting.AgentFramework.DevUI/Aspire.Hosting.AgentFramework.DevUI.csproj — Add <ProjectReference Include="..\Microsoft.Agents.AI.DevUI\Microsoft.Agents.AI.DevUI.csproj" />. Both projects import nuget-package.props, so the in-repo project reference flows through to a transitive NuGet PackageReference at pack time. A short comment in the csproj explains why the reference exists.
  • dotnet/samples/05-end-to-end/DevUIAspireIntegration/DevUIIntegration.AppHost/DevUIIntegration.AppHost.csproj — Drop the now-redundant explicit ProjectReference to Microsoft.Agents.AI.DevUI so the sample mirrors what end-users will write after this change.
  • dotnet/src/Aspire.Hosting.AgentFramework.DevUI/README.md — Rewrite the "DevUI frontend assembly" section. It previously told users to manually add Microsoft.Agents.AI.DevUI to their AppHost project; it now describes the new default behavior and the fallback path the aggregator uses when the assembly cannot be loaded (e.g., trimming/AOT settings).
  • dotnet/tests/Aspire.Hosting.AgentFramework.DevUI.UnitTests/DevUIFrontendAssemblyTests.cs (new) — Two-test regression guard that asserts (a) Assembly.Load("Microsoft.Agents.AI.DevUI") succeeds from a process that only references Aspire.Hosting.AgentFramework.DevUI, and (b) the loaded assembly exposes embedded frontend resources under the prefix the aggregator scans for. If a future change accidentally removes the new ProjectReference, these tests fail with a clear signal.

The aggregator's existing fallback path (proxy the frontend from the first backend agent service that serves /devui) is preserved unchanged for users who explicitly opt out of the embedded assets.

I was unable to run dotnet build locally because the repo pins SDK 10.0.200 in global.json and I do not have that preview installed. The csproj edits use the exact same <ProjectReference> shape as four other csprojs in the repo, and the README/sample changes are textual. CI will confirm the build.

Fixes #5779

Contribution Checklist

  • The code builds clean without any errors or warnings (CI to confirm; SDK 10.0.200 not available locally)
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible (added DevUIFrontendAssemblyTests)
  • Is this a breaking change? No. Adding a transitive dependency is additive; the aggregator's behavior when the assembly is missing is unchanged (it still falls back to proxying from a backend).

…ve dependency

Aspire.Hosting.AgentFramework.DevUI starts an in-process Kestrel aggregator
that serves the DevUI frontend from embedded resources in the
Microsoft.Agents.AI.DevUI assembly, discovered at runtime via
`Assembly.Load("Microsoft.Agents.AI.DevUI")` in DevUIAggregatorHostedService.

Until now, that package was not referenced by the Aspire integration's
.csproj, so users who followed the README's installation instructions
(`dotnet add package Aspire.Hosting.AgentFramework.DevUI`) ended up with the
aggregator but not the frontend assembly. `Assembly.Load` then failed
silently (debug-level log) and `GET /devui/` returned HTTP 404, as reported
in microsoft#5779.

The DevUIAspireIntegration sample worked around this by adding a second
ProjectReference to Microsoft.Agents.AI.DevUI in its AppHost csproj.

This change makes the dependency explicit so the integration works out of
the box:

- Aspire.Hosting.AgentFramework.DevUI.csproj now ProjectReferences
  Microsoft.Agents.AI.DevUI, so consumers get the frontend assembly
  transitively when they install Aspire.Hosting.AgentFramework.DevUI from
  NuGet.
- The redundant explicit ProjectReference is removed from the
  DevUIIntegration.AppHost sample so it mirrors what end-users will write.
- README "DevUI frontend assembly" section is updated to describe the new
  default behavior and the proxy-from-backend fallback.
- A regression test (DevUIFrontendAssemblyTests) asserts that the assembly
  is loadable via Assembly.Load and exposes embedded frontend resources, so
  the missing-reference regression cannot recur silently.

The aggregator's existing fallback path (proxy the frontend from the first
backend agent service) is preserved for users who explicitly opt out of the
embedded assets via trimming or AOT settings.

Fixes microsoft#5779
Copilot AI review requested due to automatic review settings May 17, 2026 18:08
@moonbox3 moonbox3 added documentation Improvements or additions to documentation .NET labels May 17, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Ensures the Aspire DevUI hosting integration always brings along the DevUI frontend assembly (Microsoft.Agents.AI.DevUI) so DevUIAggregatorHostedService can successfully Assembly.Load("Microsoft.Agents.AI.DevUI") in typical “single package install” scenarios, addressing the reported 404 behavior in #5779.

Changes:

  • Add a ProjectReference from Aspire.Hosting.AgentFramework.DevUI to Microsoft.Agents.AI.DevUI so the frontend assets are available transitively.
  • Update the DevUI README guidance to reflect the new default behavior and the existing fallback proxy mode.
  • Add regression unit tests that verify the assembly can be loaded and contains the expected embedded frontend resources; simplify the sample by removing the redundant direct reference.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
dotnet/src/Aspire.Hosting.AgentFramework.DevUI/Aspire.Hosting.AgentFramework.DevUI.csproj Adds a direct project dependency on Microsoft.Agents.AI.DevUI so embedded frontend assets ship transitively.
dotnet/src/Aspire.Hosting.AgentFramework.DevUI/README.md Updates documentation to describe the new transitive behavior and fallback when the assembly can’t be loaded.
dotnet/samples/05-end-to-end/DevUIAspireIntegration/DevUIIntegration.AppHost/DevUIIntegration.AppHost.csproj Removes now-redundant explicit Microsoft.Agents.AI.DevUI reference so the sample matches the end-user setup.
dotnet/tests/Aspire.Hosting.AgentFramework.DevUI.UnitTests/DevUIFrontendAssemblyTests.cs Adds regression tests validating Assembly.Load works and frontend resources are present under the expected prefix.

@hansmbakker
Copy link
Copy Markdown

hansmbakker commented May 17, 2026

Thank you for contributing this! I believe there is another PR that addresses the same issue (#5788) though - I guess only one of them is needed. I'll leave it to the Agent Framework maintainers to decide on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Bug]: Following the Aspire DevUI Readme results in 404 Not Found

4 participants