Skip to content

aspire new/run from workspace root uses root aspire.config.json (no packages) instead of project config #15623

@davidfowl

Description

@davidfowl

Description

When aspire new creates a project in a subdirectory (e.g., ./MyProject/), two aspire.config.json files end up on disk:

  1. Root config (./aspire.config.json): Created by ProjectLocator.CreateSettingsFileAsync — has appHost.path but no packages section
  2. Project config (./MyProject/aspire.config.json): Created by the template — has the packages section with integration references

When subsequently running aspire run (or during the BuildAndGenerateSdkAsync step of aspire new itself), ConfigurationService.FindNearestSettingsFile walks up from the CWD and finds the root config first. Since the root config has no packages, the NuGet restore only gets Aspire.Hosting core — no integration assemblies are loaded, and the generated TypeScript SDK is missing all integration-specific functions (e.g., addUvicornApp, addViteApp).

Steps to Reproduce

  1. mkdir workspace && cd workspace
  2. aspire new → select "Starter App (FastAPI/React)" → name it MyApp
  3. aspire run (from workspace/, NOT from workspace/MyApp/)
  4. Observe: builder.addUvicornApp is not a function

Expected Behavior

Running aspire run from the workspace root should resolve packages from the project-level aspire.config.json (which contains the packages section), not the root config.

Workaround

cd MyApp before running aspire run / aspire start. This makes the config resolution find the correct project-level config.

Root Cause

  • ProjectLocator.CreateSettingsFileAsync writes appHost.path to a root-level aspire.config.json via ConfigurationService.SetConfigurationAsync("appHost.path", ...) but does not copy the packages section from the project config.
  • GuestAppHostProject.GetConfigDirectory uses _configurationService.GetSettingsFilePath(isGlobal: false) which calls FindNearestSettingsFile — this searches from CWD upward, finding the root config before the project config.
  • The root config is authoritative for package resolution, but it has no packages.

Affected Scenarios

  • Any TypeScript AppHost template with integration packages (py-starter, ts-starter, etc.) when aspire run is invoked from a parent directory
  • The ts-starter E2E test works around this by cd-ing into the project directory before running

Possible Fixes

  1. ProjectLocator.CreateSettingsFileAsync should copy/merge the packages section from the project config into the root config
  2. Or GuestAppHostProject should resolve packages from the config nearest to the apphost file, not from CWD
  3. Or aspire run should prefer the project-level config when the root config has no packages but points to a subdirectory that does

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions