Skip to content

Load polyglot AppHost settings from project root - #19719

Merged
Sébastien Ros (sebastienros) merged 6 commits into
mainfrom
sebros/ts-apphost-configuration
Aug 31, 2026
Merged

Load polyglot AppHost settings from project root#19719
Sébastien Ros (sebastienros) merged 6 commits into
mainfrom
sebros/ts-apphost-configuration

Conversation

@sebastienros

Copy link
Copy Markdown
Contributor

Description

Polyglot AppHosts run their managed Aspire server from a CLI-owned directory, so the server-side application builder could not discover appsettings.json files next to apphost.mts or other guest AppHost files.

This change roots the inner distributed application host at the guest AppHost directory. Polyglot AppHosts now receive the standard .NET configuration stack, including appsettings.json, appsettings.{Environment}.json, environment variables, and command-line arguments. The outer JSON-RPC host continues loading its private configuration for ATS assembly discovery, while the inner host explicitly preserves the managed server's logging defaults and allows application settings to override them.

User-facing usage

Place application settings next to the guest AppHost:

{
  "Deployment": {
    "Region": "westus"
  }
}

TypeScript AppHosts can consume the resulting configuration through the generated builder API:

const builder = await createBuilder();
const configuration = await builder.getConfiguration();
const region = await configuration.getConfigValue("Deployment:Region");

Validation: DistributedApplicationBuilderTests covers base settings, environment-specific overrides, preserved managed logging defaults, and application logging overrides.

Fixes # (issue)

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • Are you including unit tests for the changes and scenario tests if relevant?
    • Yes
    • No
  • Did you add public API?
    • Yes
      • If yes, did you have an API Review for it?
        • Yes
        • No
      • Did you add <remarks /> and <code /> elements on your triple slash comments?
        • Yes
        • No
    • No
  • Does the change make any security assumptions or guarantees?
    • Yes
      • If yes, have you done a threat model and had a security review?
        • Yes
        • No
    • No

Use the guest AppHost directory as the inner host content root while preserving managed server configuration and logging defaults.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f941c2f4-38c9-45a6-8e6f-e5d6e6ff8847
Copilot AI balanced review requested due to automatic review settings August 26, 2026 19:27
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 19719

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 19719"

@github-actions github-actions Bot added the area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication label Aug 26, 2026
@github-actions

This comment has been minimized.

Comment thread src/Aspire.Hosting/DistributedApplicationBuilder.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Roots polyglot AppHost configuration at the guest project directory so standard .NET application settings are discovered.

Changes:

  • Loads environment-specific AppHost settings with standard precedence.
  • Preserves managed logging defaults while permitting overrides.
  • Adds focused tests and documents usage.

Reviewed changes

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

Show a summary per file
File Description
src/Aspire.Hosting/DistributedApplication.cs Sets the polyglot content root.
src/Aspire.Hosting/DistributedApplicationBuilder.cs Applies content root and logging defaults.
src/Aspire.Hosting/DistributedApplicationOptions.cs Adds internal content-root storage.
tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs Tests settings and logging precedence.
docs/specs/polyglot-apphost.md Documents application settings.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f941c2f4-38c9-45a6-8e6f-e5d6e6ff8847
Copilot AI review requested due to automatic review settings August 26, 2026 19:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Suppressed comments (1)

Previously missed (1) — in code that hasn't changed since the last review.

docs/specs/polyglot-apphost.md:1385

  • This is inconsistent with the implemented precedence: the inner distributed application host reapplies its Logging section after Aspire's defaults, so matching application settings can override those defaults. Distinguish the outer JSON-RPC host's private settings from the inner host's overridable logging defaults.
The managed server keeps its own internal configuration separate, so application settings do not replace ATS assembly discovery or server logging settings.

Comment thread tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs
@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f941c2f4-38c9-45a6-8e6f-e5d6e6ff8847
Copilot AI review requested due to automatic review settings August 26, 2026 22:04
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f941c2f4-38c9-45a6-8e6f-e5d6e6ff8847

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

@github-actions

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@sebastienros

Copy link
Copy Markdown
Contributor Author

PR Testing Report

PR Information

Artifact Version Verification

  • Expected Commit: e7635699c652369c51889d2fc2dfe3b0d28bce1f
  • Installed Version: 13.6.0-pr.19719.ge7635699
  • Status: Verified

Changes Analyzed

Files Changed

  • src/Aspire.Hosting/DistributedApplication.cs
  • src/Aspire.Hosting/DistributedApplicationBuilder.cs
  • src/Aspire.Hosting/DistributedApplicationOptions.cs
  • tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs
  • docs/specs/polyglot-apphost.md

Change Categories

  • CLI changes
  • Hosting changes
  • Dashboard changes
  • Template changes
  • Client/component changes
  • VS Code extension changes
  • Test changes

Test Scenarios Executed

Scenario 1: Base AppHost settings

Objective: Verify a fresh TypeScript AppHost loads appsettings.json from its project root when launched from another working directory.

Coverage Type: Happy path

Status: Passed

The AppHost read Validation:Value and exposed it as a parameter. aspire describe reported Value: base.

Evidence: base-describe.json

Scenario 2: Environment-specific settings

Objective: Verify standard environment-specific configuration works with a lowercase environment name and lowercase appsettings.production.json.

Coverage Type: Happy path and environment boundary

Status: Passed

The AppHost was started with DOTNET_ENVIRONMENT=production. The environment-specific file overrode the base value, and aspire describe reported Value: production.

Evidence: production-describe.json

Scenario 3: Existing polyglot logging defaults

Objective: Verify an existing TypeScript AppHost without logging JSON preserves the managed AppHost logging defaults.

Coverage Type: Backward compatibility

Status: Passed

The resolved values were:

  • Logging:LogLevel:Default: Information
  • Logging:LogLevel:Microsoft.AspNetCore: Warning
  • Logging:LogLevel:Aspire.Hosting.Dcp: Warning

Evidence: logging-defaults-describe.json

Scenario 4: User logging override

Objective: Verify AppHost-root JSON remains authoritative over the low-priority compatibility defaults.

Coverage Type: Precedence boundary

Status: Passed

Setting Logging:LogLevel:Aspire.Hosting.Dcp to Trace in appsettings.json produced Trace, while the unspecified Microsoft.AspNetCore category remained Warning.

Evidence: logging-override-describe.json

Scenario 5: Malformed AppHost settings

Objective: Verify invalid AppHost-root JSON fails safely with an actionable diagnostic.

Coverage Type: Unhappy path

Status: Passed

An invalid JSON token caused exit code 2. The error identified the exact AppHost-root appsettings.json and reported Failed to load configuration from file.

Evidence: malformed-start-stderr.txt, malformed-start-exit-code.txt

Summary

Scenario Status Notes
Base AppHost settings Passed Loaded from the TypeScript AppHost root
Environment-specific settings Passed Lowercase Production environment override applied
Existing logging defaults Passed Information, Warning, Warning preserved
User logging override Passed AppHost JSON overrode only the configured category
Malformed AppHost settings Passed Exit code 2 with file-specific diagnostic

Overall Result

PR VERIFIED

The PR artifact at the current head passed all five targeted Linux scenarios. The runner image did not include Node.js/npm, so those execution prerequisites were installed inside the ephemeral test container before running the generated TypeScript projects.

@IEvangelist

Copy link
Copy Markdown
Member

Could you add some TS tests that prove this works as well, the current tests are using the C# AppHost approach. It'd be great to have some real TS verification for this. Some scenarios I'd like to see covered is JSON files, overrides, environment-specific, like you've done with the .NET tests - but not in TS, verifying that the full e2e works. Bonus points for proving contextual env vars flow from e2e too.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot-Session: f941c2f4-38c9-45a6-8e6f-e5d6e6ff8847
Copilot AI review requested due to automatic review settings August 27, 2026 19:56

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

Copilot AI review requested due to automatic review settings August 27, 2026 20:57
@github-actions

Copy link
Copy Markdown
Contributor

Tests selector (audit mode)

The full test matrix and all jobs still run in audit mode. The tests and jobs below are what selective CI would run under enforcement.

51 / 102 test projects · 4 jobs, from 9 changed files.

Selected test projects (51 / 102)

Aspire.EndToEnd.Tests, Aspire.Hosting.Analyzers.Tests, Aspire.Hosting.Azure.Kubernetes.Tests, Aspire.Hosting.Azure.Kusto.Tests, Aspire.Hosting.Azure.Tests, Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Browsers.Tests, Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests, Aspire.Hosting.DevTunnels.Tests, Aspire.Hosting.Docker.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.DotnetTool.Tests, Aspire.Hosting.EntityFrameworkCore.Tests, Aspire.Hosting.Foundry.Tests, Aspire.Hosting.Garnet.Tests, Aspire.Hosting.GitHub.Models.Tests, Aspire.Hosting.Go.Tests, Aspire.Hosting.Java.Tests, Aspire.Hosting.JavaScript.Tests, Aspire.Hosting.Kafka.Tests, Aspire.Hosting.Keycloak.Tests, Aspire.Hosting.Kubernetes.Tests, Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests, Aspire.Hosting.MongoDB.Tests, Aspire.Hosting.MySql.Tests, Aspire.Hosting.Nats.Tests, Aspire.Hosting.OpenAI.Tests, Aspire.Hosting.Oracle.Tests, Aspire.Hosting.Orleans.Tests, Aspire.Hosting.PostgreSQL.Tests, Aspire.Hosting.Python.Tests, Aspire.Hosting.Qdrant.Tests, Aspire.Hosting.RabbitMQ.Tests, Aspire.Hosting.Radius.Tests, Aspire.Hosting.Redis.Tests, Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests, Aspire.Hosting.Seq.Tests, Aspire.Hosting.SqlServer.Tests, Aspire.Hosting.Testing.Tests, Aspire.Hosting.Tests, Aspire.Hosting.Valkey.Tests, Aspire.Hosting.Yarp.Tests, Aspire.Playground.Tests, Infrastructure.Tests

Selected jobs (4)

deployment-e2e, extension-e2e, polyglot, typescript-api-compat


How these were chosen — grouped by what changed

⚠️ 45 of the 51 selected test projects come from a single change — src/Aspire.Hosting/DistributedApplication.cs.

🔧 src/Aspire.Hosting/DistributedApplication.cs (changed source)
45 via the project graph

show 45

Aspire.Hosting.Analyzers.Tests (2 hops), Aspire.Hosting.Azure.Kubernetes.Tests (2 hops), Aspire.Hosting.Azure.Kusto.Tests (2 hops), Aspire.Hosting.Azure.Tests, Aspire.Hosting.Browsers.Tests (2 hops), Aspire.Hosting.CodeGeneration.Go.Tests, Aspire.Hosting.CodeGeneration.Java.Tests, Aspire.Hosting.CodeGeneration.Python.Tests, Aspire.Hosting.CodeGeneration.Rust.Tests, Aspire.Hosting.CodeGeneration.TypeScript.Tests, Aspire.Hosting.Containers.Tests (2 hops), Aspire.Hosting.DevTunnels.Tests (2 hops), Aspire.Hosting.Docker.Tests (2 hops), Aspire.Hosting.DotnetTool.Tests (2 hops), Aspire.Hosting.EntityFrameworkCore.Tests (2 hops), Aspire.Hosting.Foundry.Tests (2 hops), Aspire.Hosting.Garnet.Tests (2 hops), Aspire.Hosting.GitHub.Models.Tests (2 hops), Aspire.Hosting.Go.Tests (2 hops), Aspire.Hosting.Java.Tests (2 hops), Aspire.Hosting.JavaScript.Tests (2 hops), Aspire.Hosting.Kafka.Tests (2 hops), Aspire.Hosting.Keycloak.Tests (2 hops), Aspire.Hosting.Kubernetes.Tests (2 hops), Aspire.Hosting.Maui.Tests, Aspire.Hosting.Milvus.Tests (2 hops), Aspire.Hosting.MongoDB.Tests (2 hops), Aspire.Hosting.MySql.Tests (2 hops), Aspire.Hosting.Nats.Tests (2 hops), Aspire.Hosting.OpenAI.Tests (2 hops), Aspire.Hosting.Oracle.Tests (2 hops), Aspire.Hosting.Orleans.Tests (2 hops), Aspire.Hosting.PostgreSQL.Tests (2 hops), Aspire.Hosting.Python.Tests (2 hops), Aspire.Hosting.Qdrant.Tests (2 hops), Aspire.Hosting.RabbitMQ.Tests (2 hops), Aspire.Hosting.Redis.Tests (2 hops), Aspire.Hosting.RemoteHost.Tests, Aspire.Hosting.Rust.Tests (2 hops), Aspire.Hosting.Seq.Tests (2 hops), Aspire.Hosting.SqlServer.Tests (2 hops), Aspire.Hosting.Testing.Tests (2 hops), Aspire.Hosting.Valkey.Tests (2 hops), Aspire.Hosting.Yarp.Tests (2 hops), Aspire.Playground.Tests

🧪 tests/Aspire.Hosting.Tests/DistributedApplicationBuilderTests.cs (changed test)
1 directly: Aspire.Hosting.Tests
3 via the project graph: Aspire.Hosting.Blazor.Tests, Aspire.Hosting.Dotnet.Tests, Aspire.Hosting.Radius.Tests

📦 affected project Aspire.Hosting
1 test: Aspire.EndToEnd.Tests

📄 .github/workflows/polyglot-validation/test-go.sh (changed)
1 directly: Infrastructure.Tests

📄 .github/workflows/polyglot-validation/test-java.sh (changed)
1 directly: Infrastructure.Tests

📄 .github/workflows/polyglot-validation/test-python.sh (changed)
1 directly: Infrastructure.Tests

📄 .github/workflows/polyglot-validation/test-rust.sh (changed)
1 directly: Infrastructure.Tests

📄 .github/workflows/polyglot-validation/test-typescript.sh (changed)
1 directly: Infrastructure.Tests

Job reasons

Job Triggered by
deployment-e2e affected project Aspire.Hosting.Azure
extension-e2e src/Aspire.Hosting/DistributedApplication.cs, src/Aspire.Hosting/DistributedApplicationBuilder.cs, src/Aspire.Hosting/DistributedApplicationOptions.cs
• affected project Aspire.Hosting
polyglot .github/workflows/polyglot-validation/test-go.sh, .github/workflows/polyglot-validation/test-java.sh, .github/workflows/polyglot-validation/test-python.sh, .github/workflows/polyglot-validation/test-rust.sh, .github/workflows/polyglot-validation/test-typescript.sh
• affected project Aspire.Hosting.Rust
typescript-api-compat affected project Aspire.Hosting

Selection computed for commit 31f5f11.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

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

@github-actions

Copy link
Copy Markdown
Contributor

Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt.

@sebastienros
Sébastien Ros (sebastienros) merged commit ade22c6 into main Aug 31, 2026
772 of 775 checks passed
@sebastienros
Sébastien Ros (sebastienros) deleted the sebros/ts-apphost-configuration branch August 31, 2026 19:02
@github-actions github-actions Bot added this to the 13.6 milestone Aug 31, 2026
aspire-repo-bot Bot added a commit to microsoft/aspire.dev that referenced this pull request Aug 31, 2026
Documents that polyglot (TypeScript) AppHosts now load appsettings.json
and appsettings.{Environment}.json from the guest AppHost directory,
per microsoft/aspire#19719.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@aspire-repo-bot

Copy link
Copy Markdown
Contributor

Pull request created: #1597

Generated by PR Documentation Check · auto · 106.9 AIC · ⌖ 14.3 AIC · ⊞ 19.6K

@aspire-repo-bot

Copy link
Copy Markdown
Contributor

📝 Documentation has been drafted in microsoft/aspire.dev#1597 targeting release/13.6.

Added a new "Configuration with appsettings.json" section to src/frontend/src/content/docs/app-host/typescript-apphost.mdx, documenting that TypeScript AppHosts can now load appsettings.json/appsettings.{Environment}.json from the guest AppHost directory and read values via builder.getConfiguration() / configuration.getConfigValue(...).

Note

This draft PR needs human review before merging.

@github-actions

Copy link
Copy Markdown
Contributor

🔍 CI Failure Analysis: Transient Infrastructure Failure

The CI build failed due to transient infrastructure issues.

Failed jobs:

  • Tests / Templates-XUnit_Default_NewUpAndBuildSupportProjectTemplatesTests / Templates-XUnit_Default_NewUpAndBuildSupportProjectTemplatesTests (macos-latest) — Job failed during 'Set up job' step before any PR code executed. The GitHub Actions runner failed to parse the actions/checkout action.yml manifest, reporting a corrupted/empty YAML download (System.ArgumentException: Unexpected type '' encountered while reading 'action manifest root'). This is a known recurring GitHub-hosted runner infrastructure issue unrelated to PR content. (transient-infra)

If a rerun was not already requested automatically, visit the workflow run page to rerun the failed jobs manually.

David Pine (IEvangelist) added a commit to microsoft/aspire.dev that referenced this pull request Sep 1, 2026
* docs: document appsettings.json support for TypeScript AppHosts

Documents that polyglot (TypeScript) AppHosts now load appsettings.json
and appsettings.{Environment}.json from the guest AppHost directory,
per microsoft/aspire#19719.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Reframe TS AppHost appsettings docs as a JSON config system

Rewrite the Configuration section on the TypeScript AppHost page to describe appsettings.json purely as a JSON configuration system for TypeScript, using camelCase keys, a case-insensitive lookup note, and an ASPIRE_ENVIRONMENT-based environment section.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Show aspire start --environment switch and link CLI reference

Replace the ASPIRE_ENVIRONMENT example with the single aspire start --environment CLI command, add a LearnMore link to the aspire start CLI reference, and drop the now-unused OsAwareTabs import.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

* Potential fix for pull request finding

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

* Apply suggestion from @IEvangelist

* docs: clarify TypeScript AppHost config flow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: aspire-repo-bot[bot] <268009190+aspire-repo-bot[bot]@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: David Pine <david.pine@microsoft.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: David Pine <7679720+IEvangelist@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-app-model Issues pertaining to the APIs in Aspire.Hosting, e.g. DistributedApplication

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants