agentleFS
MicrosoftKnown publishermicrosoft/aspire/AGENTS.md

aspire

AGENTS.md6.3k starsChanged 6 months agoMITView on GitHub

Instructions for GitHub Copilot and other AI coding agents working with the Aspire repository. Aspire provides tools, templates, and packages for building observable, production-ready distributed applications. At its core is an app model that defines services, resources, and connections in a code-first approach. When reviewing a pull request, check whether eng/github-ci/test-trigger-map.yml needs to change if the diff: * Adds, removes, or renames a test project. * Adds or changes a CI job, reusable workflow, or run_* selection gate. * Adds…

Trending

Quiet since September.about the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 2 mentionsApr 2026: 1 mentionMay 2026: 5 mentionsJun 2026: 4 mentionsJul 2026: 1 mentionAug 2026: 4 mentionsSep 2026: 3 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the microsoft/aspire repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about microsoft/aspire

The biggest 5 of 20 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 20

Talked about on GitHub and Bluesky (20 times).

On GitHub · 18

13 more on GitHub

The file

Show its rules and text

We split this AGENTS.md into the rules it gives an agent

60 rules. About 0 are common, 30 are distinctive, and 30 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈30

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 30

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Always use the latest version C#, currently C# 13 features.

    line 28
  2. Very specific:

    Never change global.json unless explicitly asked to.

    line 29
  3. Very specific:

    Never change package.json or package-lock.json files unless explicitly asked to.

    line 30
  4. Distinctive:

    Never change NuGet.config files unless explicitly asked to.

    line 31
  5. Very specific:

    Do not use cryptographic hashes such as SHA-256 when the hash is not security-related.

    line 32
  6. Very specific:

    When code needs a temporary directory, prefer the repository temp directory abstractions first (for example …

    line 33
  7. Very specific:

    Don't update files under */api/*.cs (e.g.

    line 34
  8. Very specific:

    When reviewing a pull request, check whether eng/github-ci/test-trigger-map.yml needs to change if the diff:

    line 41
  9. Very specific:

    Do not request manual mappings for files evaluated by projects in the Aspire.slnx-rooted ProjectGraph.

    line 55
  10. Very specific:

    Keep each trigger-map reason concise: state what the rule covers or why the target consumes the input.

    line 83
  11. Very specific:

    Treat a relaxed negative expectation as a signal to verify the consuming workflow's artifacts and execution lane.

    line 112
  12. Very specific:

    When reviewing official Azure Pipelines YAML changes, validate them by running the internal microsoft-aspire pipeline (definition 1602 in …

    line 118
  13. Distinctive:

    When reviewing pull requests:

    line 135
  14. Distinctive:

    Only flag API file concerns if:

    line 140
  15. Distinctive:

    If a PR adds an external feed, request that:

    line 157
  16. Distinctive:

    Use existing internal feeds that already mirror public packages (like dotnet-public, dotnet-eng)

    line 159
  17. Distinctive:

    When authoring or reviewing any change that modifies a pinned action SHA (including bulk regeneration such as gh-aw workflow updates):

    line 170
  18. Distinctive:

    Verify each newly introduced SHA is permitted by the repository/enterprise allowed-actions policy.

    line 174
  19. Distinctive:

    Treat a changed pin without a confirmed matching allow-list update as a blocking review issue.

    line 179
  20. Very specific:

    Do not request allow-list changes when a pin is unchanged, or for first-party actions/* actions already covered by policy.

    line 181
  21. Distinctive:

    Prefer file-scoped namespace declarations and single-line using directives.

    line 191
  22. Distinctive:

    Ensure that the final return statement of a method is on its own line.

    line 193
  23. Distinctive:

    Use pattern matching and switch expressions wherever possible.

    line 194
  24. Very specific:

    Use nameof instead of string literals when referring to member names.

    line 195
  25. Distinctive:

    Place private class declarations at the bottom of the file.

    line 196
  26. Distinctive:

    Do comment non-obvious implementation details: concurrency hazards, lifecycle constraints, compatibility requirements, platform quirks, …

    line 201
  27. Distinctive:

    When parsing strings, logs, command output, protocol payloads, or other loosely structured data, include a comment with an example of the …

    line 202
  28. Distinctive:

    When code follows an external standard, protocol, or ecosystem convention, include valid links to the relevant source material so future …

    line 203
  29. Distinctive:

    Do not add comments that simply narrate clear code, such as "set the timeout" immediately before assigning a timeout.

    line 204
  30. Distinctive:

    Keep workaround comments close to the workaround.

    line 205
  31. Distinctive:

    Avoid comments that restate the code:

    line 301
  32. Very specific:

    Always use is null or is not null instead of == null or != null.

    line 314
  33. Very specific:

    Restore First: Always run ./restore.sh (Linux/macOS) or ./restore.cmd (Windows) to set up the local .NET SDK (~30 seconds)

    line 322
  34. Very specific:

    Skip Native Build: Add /p:SkipNativeBuild=true to avoid slow native AOT compilation (~1-2 minutes saved)

    line 327
  35. Very specific:

    If you need to disable the terminal logger for dotnet/build-related commands, prefer setting MSBUILDTERMINALLOGGER=false instead of passing …

    line 330
  36. Very specific:

    If temporarily introducing warnings during refactoring, add /p:TreatWarningsAsErrors=false to prevent build failure

    line 333
  37. Distinctive:

    Important: All warnings should be addressed before committing any final changes

    line 334
  38. Very specific:

    If build fails with SDK errors, run ./restore.sh again to ensure correct .NET 10 RC is installed

    line 336
  39. Very specific:

    VS Code: Run ./build.sh first, then use ./start-code.sh to launch with correct environment

    line 340
  40. Very specific:

    Visual Studio: Run ./build.cmd first, then use ./startvs.cmd to launch with local SDK environment

    line 341
  41. Distinctive:

    Run the App Host in the background so it continues running while you execute other commands:

    line 347
  42. Distinctive:

    Do not emit "Act", "Arrange" or "Assert" comments.

    line 378
  43. Distinctive:

    Do not leave newly-added tests commented out.

    line 381
  44. Distinctive:

    Do not use Directory.SetCurrentDirectory in tests as it can cause side effects when tests execute concurrently.

    line 382
  45. Very specific:

    Use Verify (snapshot testing) for generated artifacts (files, serialized output, structured text).

    line 385
  46. Very specific:

    Avoid Assert.DoesNotContain as it is a weak assertion that easily goes out of date — it only proves something is absent without verifying …

    line 386
  47. Very specific:

    Important: Avoid passing --no-build unless you have just built in the same session and there have been no code changes since.

    line 407
  48. Very specific:

    All test filtering must use MTP-native switches placed after --.

    line 422
  49. Distinctive:

    When running tests in automated environments (including Copilot agent), always exclude quarantined and outerloop tests to avoid false …

    line 426
  50. Distinctive:

    Never run all tests without the quarantine and outerloop filters in automated environments, as this will include flaky tests that are known …

    line 436
  51. Distinctive:

    Workflow matcher maintenance: When changing CI workflow job or step names that are referenced by automation or tests, update the …

    line 476
  52. Very specific:

    Instead they are run in the Quarantine workflow (tests-quarantine.yml).

    line 499
  53. Distinctive:

    Use these commands in any issue or PR comment.

    line 508
  54. Very specific:

    When you comment on a PR, the changes are automatically pushed to that PR's branch (no need for --target-pr).

    line 527
  55. Very specific:

    Use this for tests that are blocked, not for flaky tests (use QuarantinedTest for flaky tests).

    line 545
  56. Distinctive:

    When tests that use snapshot testing are updated and generate new output, the snapshots need to be accepted.

    line 589
  57. Very specific:

    Use dotnet verify accept -y to accept all pending snapshot changes after running tests.

    line 590
  58. Very specific:

    Do not manually edit *.xlf files.

    line 603
  59. Distinctive:

    When possible, you should create Typescript files instead of Javascript files.

    line 624
  60. Very specific:

    When displaying text to the user, ensure that the strings are localized.

    line 629

≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

Agent Instructions

Instructions for GitHub Copilot and other AI coding agents working with the Aspire repository.

Repository Overview

Aspire provides tools, templates, and packages for building observable, production-ready distributed applications. At its core is an app model that defines services, resources, and connections in a code-first approach.

Key Components

  • Aspire.Hosting: Application host orchestration and resource management
  • Aspire.Dashboard: Web-based dashboard for monitoring and debugging
  • Service Discovery: Infrastructure for service-to-service communication
  • Integrations: 40+ packages for databases (SQL Server, PostgreSQL, Redis, MongoDB), message queues (RabbitMQ, Kafka), cloud services (Azure), and more
  • CLI Tools: Command-line interface for project creation and management
  • Project Templates: Starter templates for new Aspire applications

Technology Stack

  • .NET 10.0
  • C# 13 preview features
  • xUnit SDK v3 with Microsoft.Testing.Platform for testing
  • Microsoft.DotNet.Arcade.Sdk for build infrastructure
  • Native AOT compilation for CLI tools
  • Multi-platform support (Windows, Linux, macOS, containers)

General

  • Make only high confidence suggestions when reviewing code changes.
  • Always use the latest version C#, currently C# 13 features.
  • Never change global.json unless explicitly asked to.
  • Never change package.json or package-lock.json files unless explicitly asked to.
  • Never change NuGet.config files unless explicitly asked to.
  • Do not use cryptographic hashes such as SHA-256 when the hash is not security-related. Prefer System.IO.Hashing.XxHash3 when you need a stable non-cryptographic hash.
  • When code needs a temporary directory, prefer the repository temp directory abstractions first (for example IFileSystemService.TempDirectory / ITempFileSystemService) and otherwise use Directory.CreateTempSubdirectory() instead of Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); if you need a temporary file path, place it under a securely created temp directory.
  • Don't update files under */api/*.cs (e.g. src/Aspire.Hosting/api/Aspire.Hosting.cs) as they are generated.
  • Do not make new parameters optional just to avoid updating call sites. A parameter should only be optional when it has a sensible semantic default and the API is frequently used (where call-site brevity outweighs explicitness). If a parameter is logically required, make it required and update all call sites.

Code Review Instructions

Conditional Test Selection

When reviewing a pull request, check whether eng/github-ci/test-trigger-map.yml needs to change if the diff:

  • Adds, removes, or renames a test project.
  • Adds or changes a CI job, reusable workflow, or run_* selection gate.
  • Adds or changes a script, configuration file, or other loose input consumed by CI or tests but not represented by an MSBuild project reference.
  • Adds, removes, or changes a runtime-only dependency on a repository-built package, template, or fixture. Examples include packages loaded by aspire add, generated AppHosts, package filters in E2E tests, and files copied into an E2E workspace.
  • Adds, removes, or conditionally changes QuarantinedTest, ActiveIssue, or OuterloopTest on an E2E scenario with runtime-only dependencies.

Do not request manual mappings for files evaluated by projects in the Aspire.slnx-rooted ProjectGraph; Layer 1 owns them. For Layer 2 blind spots, verify that the map routes each path to its actual consumer, uses ALL for broad shared inputs, or explicitly classifies paths handled by unconditional or dedicated workflows and paths with no PR-CI consumer. A gated job implemented by a reusable workflow must route changes to that workflow file to the job target and keep its run_* output wiring consistent.

For runtime-only consumers that ProjectGraph cannot see, require an affected_project_rules entry for actual production/non-test project consumers, a path_rules entry for loose or runtime inputs not represented by ProjectGraph, or a derived_targets entry when selecting one test inherently requires another target. Because affected_project_rules evaluate only production projects and never match projects under tests/, a runtime-only test or test-support consumer must use path or derived-target routing instead. Project-name patterns use globs, not regular expressions. For expensive or class-sharded targets, prefer exact project names; use a family glob only when every current and future matching project should run that target. When a PR changes the packages or fixtures an E2E scenario consumes, add or remove the corresponding trigger-map entry in the same PR.

For a dedicated package-input directory in path_rules, prefer one stable directory glob when enumerating individual files or RIDs would let a new input silently miss its consumers. Split by RID only when the savings justify that maintenance risk and focused coverage guards every deliberate exclusion. Do not flag intentional cross-RID over-selection when the rule records this resilience tradeoff.

Keep each trigger-map reason concise: state what the rule covers or why the target consumes the input. Add detail only for a non-obvious relationship or constraint. Do not use reason to narrate the PR, duplicate the full rule, or record investigation history. The targets field is the source of truth for the target list; do not enumerate those target names again in reason. A category-level description is sufficient; the reason does not need to explain every target or make the rule self-contained. Keep discussion of alternative rule shapes or why a glob was split or broadened in the PR or maintenance documentation.

Apply that precision to expensive or class-sharded selector-gated work. For smaller unsharded jobs, prefer safe broad routing when an exhaustive consumer list would add fragility for little CI savings. Do not expand or refine advisory targets that gate no PR jobs in an unrelated PR focused on PR-gated work; audit them when their workflow or routing is intentionally in scope.

Match runtime-only edges to the target's execution lane. A regular-PR target is justified only by scenarios that run in regular PR CI; quarantined, disabled, and outerloop-only consumers do not qualify. When a scheduling attribute moves a scenario into or out of regular PR CI, update the exact trigger-map edge and focused regression coverage in the same PR.

Selector behavior changes should include focused coverage in tests/Infrastructure.Tests/TestTriggerMap/. Audit the complete curated consumer and path lists whenever a PR changes routing or runtime consumption; tests are regression guards, not a second copy of that audit. Cover each distinct heavy-target routing boundary with a representative positive, record deliberate exclusions in focused negative cases, and add a structural assertion when the same consumer list is intentionally duplicated across rule types. Treat a relaxed negative expectation as a signal to verify the consuming workflow's artifacts and execution lane. See docs/ci/test-trigger-map.md for the map vocabulary and maintenance guidance.

Official Azure Pipelines validation

When reviewing official Azure Pipelines YAML changes, validate them by running the internal microsoft-aspire pipeline (definition 1602 in dnceng/internal) and checking the relevant stage's timeline, logs, and artifacts. A green GitHub PR check or a test that asserts the YAML's exact command string does not prove the pipeline behavior. Keep non-obvious rationale next to the YAML change instead of duplicating it in exact-string tests. Use the azdo-internal skill for validation; explicitly record stages excluded by personal-branch gating (such as source indexing on main) as unvalidated, not passed.

Visual-only styling changes

When reviewing a pull request, do not request automated tests solely for visual-only styling changes, including CSS selectors, colors, opacity, cursors, hover/focus/active appearance, or theme tokens. In particular, do not request Playwright assertions for computed styles or exact color values. Tests are appropriate when a styling change also affects functional interaction, DOM or accessibility semantics, state transitions, or whether a user can complete a workflow.

API Files and Public API Surface

The API files located in */api/*.cs (e.g., src/Aspire.Hosting/api/Aspire.Hosting.cs) track the public API surface that has already been shipped in the latest release. These files are auto-generated and serve as a baseline for API compatibility checks.

When reviewing pull requests:

  • Do not comment when new public API is introduced and the API files are not regenerated. This is expected behavior during active development between releases.
  • New public APIs should be reviewed for design, naming, and functionality, but the absence of API file updates during PR development is normal.
  • API files are regenerated as part of the release process when we ship a new version, not during individual PRs.
  • Only flag API file concerns if:
    • API files are manually edited (they should never be manually modified)
    • There are breaking changes to existing APIs without proper justification
    • The PR explicitly claims to update API compatibility but doesn't regenerate the files

NuGet Feed Configuration

The NuGet.config file defines approved package sources for the internal build. External package feeds can break the internal build pipeline.

When reviewing pull requests:

  • Flag any changes to NuGet.config that add package sources not from these approved domains:
    • https://pkgs.dev.azure.com/dnceng
    • https://dnceng.pkgs.visualstudio.com/public
  • Flag any additions of external NuGet feeds such as:
    • https://api.nuget.org/v3/index.json (nuget.org)
    • Any other public or third-party package sources
  • If a PR adds an external feed, request that:
    • The packages be mirrored to an approved internal feed, or
    • Use existing internal feeds that already mirror public packages (like dotnet-public, dotnet-eng)
  • The wildcard pattern mappings (<package pattern="*" />) in dotnet-public and dotnet-eng feeds typically provide access to commonly-used public packages

Pinned GitHub Actions and the Actions Allow-List

Third-party actions in .github/workflows/** are pinned to immutable commit SHAs (owner/repo[/path]@<sha>). The repository/enterprise GitHub Actions policy allows only specific SHAs, and that allow-list lives in repository/organization settings, outside git. A workflow that references a SHA missing from the allow-list fails at runtime with an "actions not allowed" error, even though the PR itself builds and reviews cleanly.

When authoring or reviewing any change that modifies a pinned action SHA (including bulk regeneration such as gh-aw workflow updates):

  • Identify every changed owner/repo[/path]@<sha> reference in the diff.
  • Verify each newly introduced SHA is permitted by the repository/enterprise allowed-actions policy. Verify by SHA, not by tag name.
  • Coordinate the allow-list update in repository/organization settings as part of the same change, before merging. The PR cannot make that settings change itself, so the PR description must call out which SHAs an admin needs to add.
  • Treat a changed pin without a confirmed matching allow-list update as a blocking review issue.
  • Do not request allow-list changes when a pin is unchanged, or for first-party actions/* actions already covered by policy.

Example: PR #20209 bumped dotnet/issue-labeler/* from 46125e85e6a568dc712f358c39f35317366f5eed (v2.0.0) to 160b6b1e1e8d36da09beb34ef1e4806d2c0520a3 (v2.2.0) without the corresponding allow-list update, which broke the labeler workflows (issue #20277).

Formatting

  • Apply code-formatting style defined in .editorconfig.
  • Prefer file-scoped namespace declarations and single-line using directives.
  • Insert a newline before the opening curly brace of any code block (e.g., after if, for, while, foreach, using, try, etc.).
  • Ensure that the final return statement of a method is on its own line.
  • Use pattern matching and switch expressions wherever possible.
  • Use nameof instead of string literals when referring to member names.
  • Place private class declarations at the bottom of the file.

Code comments

  • Err on the side of over-commenting code when the reasoning is not obvious. Comments should explain WHY code is written a particular way; the WHY is the most important part.
  • Do comment non-obvious implementation details: concurrency hazards, lifecycle constraints, compatibility requirements, platform quirks, upstream workarounds, and intentional deviations from the obvious helper or API.
  • When parsing strings, logs, command output, protocol payloads, or other loosely structured data, include a comment with an example of the raw format being parsed. Show edge cases, escaping rules, delimiters, optional fields, or malformed-but-observed inputs when they affect the parser.
  • When code follows an external standard, protocol, or ecosystem convention, include valid links to the relevant source material so future readers can verify the rule and understand why the code follows it.
  • Do not add comments that simply narrate clear code, such as "set the timeout" immediately before assigning a timeout.
  • Keep workaround comments close to the workaround. Include an issue link when the workaround is tied to an upstream bug, and describe the condition for removing it when that is known.

Good comments explain the constraint or tradeoff:

// Read both streams concurrently to avoid deadlock when a pipe buffer fills.
var stdoutTask = process.StandardOutput.ReadToEndAsync();
var stderrTask = process.StandardError.ReadToEndAsync();
// Endpoint adoption runs on the command path, so fail quickly when stale metadata
// points at a dead or reused port.
var timeout = TimeSpan.FromSeconds(2);
// The temporary config is disposed when this method returns. That is intentional:
// only `dotnet new install` consumes the config; later template creation uses the
// already-installed template hive and ambient NuGet configuration.
using var temporaryConfig = await TemporaryNuGetConfig.CreateAsync(mappings);
// Workaround for an upstream library bug on Windows where URI SANs are formatted
// differently than the verifier expects. Cryptographic verification still runs;
// only the identity checks are performed manually from the certificate extensions.
var result = await VerifyWithManualIdentityFallbackAsync(bundle, cancellationToken);
public required IReadOnlyList<PipelineStep> Steps
{
    get;
    init
    {
        field = value;
        // IMPORTANT: The ResourceNameComparer must be used here to ensure correct lookup behavior
        // based on resource names, NOT the default reference equality. This is because resources
        // may be swapped out (referred to as bait-and-switch) during model transformations.
        StepToResourceMap = field.ToLookup(s => s.Resource, s => s, new ResourceNameComparer());
    }
}
// Output sensitive message content for GenAI.
// A convention for libraries that output GenAI telemetry is to use
// `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT`.
// See:
// - https://opentelemetry.io/blog/2024/otel-generative-ai/
// - https://github.com/search?q=org%3Aopen-telemetry+OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT&type=code
context.EnvironmentVariables[KnownOtelConfigNames.InstrumentationGenAiCaptureMessageContent] = "true";
// If we have multiple endpoints for the same scheme, differentiate them by appending a number.
// Start numbering with the second endpoint so the first stays just http/https, which preserves
// the same behavior as "dotnet run". Only do this in Run mode because, in Publish mode, those
// extra endpoints with generic names would not be easily usable.
var endpointName = bindingAddress.Scheme;
if (endpointCountByScheme[bindingAddress.Scheme] > 1)
{
    endpointName += endpointCountByScheme[bindingAddress.Scheme];
}
// The implementation here is less than ideal, but we don't have a clean way of building resource
// types that change their behavior based on context. In this case, publish mode needs the resource
// to behave like a ContainerResource instead of a ProjectResource, so we remove the ProjectResource
// from the application model and add a new ContainerResource in its place.
//
// There are still dangling references to the original ProjectResource in the application model, but
// in publish mode it won't be used. This is a limitation of the current design.
builder.ApplicationBuilder.Resources.Remove(builder.Resource);

Parsing comments should show the raw shape and important edge cases:

// Parse resource log lines emitted as:
//   [2026-05-10T18:34:22.123Z] frontend stdout: Now listening on: http://localhost:5221
// The message can contain additional ':' characters, so split only on the first
// " stdout: " or " stderr: " delimiter after the resource name.
var match = s_logLineRegex.Match(line);
// The endpoint metadata sidecar uses the DevTools /json/version shape:
//   { "webSocketDebuggerUrl": "ws://127.0.0.1:50981/devtools/browser/<id>" }
// Older Chromium builds can omit the property while the browser is still starting;
// treat that as a retryable probe failure rather than invalid metadata.
var endpoint = payload.WebSocketDebuggerUrl;

Avoid comments that restate the code:

// Set the timeout to two seconds.
var timeout = TimeSpan.FromSeconds(2);

// Create a list.
var resources = new List<Resource>();

Nullable Reference Types

  • Declare variables non-nullable, and check for null at entry points.
  • Always use is null or is not null instead of == null or != null.
  • Trust the C# null annotations and don't add null checks when the type system says a value cannot be null.

Building

Always run restore first to set up the local SDK. Run ./restore.sh (Linux/macOS) or ./restore.cmd (Windows) first to install the local SDK. After restore, you can use standard dotnet commands, which will automatically use the local SDK when available due to the paths configuration in global.json.

Prerequisites

  1. Restore First: Always run ./restore.sh (Linux/macOS) or ./restore.cmd (Windows) to set up the local .NET SDK (~30 seconds)

Build Commands

  • Full Build: ./build.sh (Linux/macOS) or ./build.cmd (Windows) - defaults to restore + build (~3-5 minutes)
  • Build Only: ./build.sh --build (assumes restore already done)
  • Skip Native Build: Add /p:SkipNativeBuild=true to avoid slow native AOT compilation (~1-2 minutes saved)
  • Clean Build: ./build.sh --rebuild
  • Package Generation: ./build.sh --pack to create NuGet packages
  • If you need to disable the terminal logger for dotnet/build-related commands, prefer setting MSBUILDTERMINALLOGGER=false instead of passing -tl:false; avoid -tl:false on commands that may invoke tests because it can be forwarded to the test host and fail under Microsoft.Testing.Platform native runner mode

Build Troubleshooting

  • If temporarily introducing warnings during refactoring, add /p:TreatWarningsAsErrors=false to prevent build failure
  • Important: All warnings should be addressed before committing any final changes
  • Template engine warnings about "Missing generatorVersions" are expected and not errors
  • If build fails with SDK errors, run ./restore.sh again to ensure correct .NET 10 RC is installed
  • Build artifacts go to ./artifacts/ directory

Visual Studio / VS Code Setup

  • VS Code: Run ./build.sh first, then use ./start-code.sh to launch with correct environment
  • Visual Studio: Run ./build.cmd first, then use ./startvs.cmd to launch with local SDK environment

Start App Hosts in a background job

When running an App Host from an interactive console (for example, PowerShell or a terminal session you plan to reuse), start it in a background job/process. If you start the App Host in the foreground and then reuse the console for another command (or stop the current interactive session), the App Host process can be terminated.

Run the App Host in the background so it continues running while you execute other commands:

PowerShell (Start-Job)

# From the AppHost project directory
Start-Job -Name "AspireAppHost" -ScriptBlock { dotnet run }

# Inspect output / state
Get-Job -Name "AspireAppHost" | Format-List *
Receive-Job -Name "AspireAppHost" -Keep

# Stop when done
Stop-Job -Name "AspireAppHost"
Remove-Job -Name "AspireAppHost"

bash (background process)

# From the AppHost project directory
dotnet run > apphost.log 2>&1 &

# Find and stop later
ps aux | grep dotnet
kill <pid>

Testing

  • We use xUnit SDK v3 with Microsoft.Testing.Platform (https://learn.microsoft.com/dotnet/core/testing/microsoft-testing-platform-intro)
  • Do not emit "Act", "Arrange" or "Assert" comments.
  • We do not use any mocking framework at the moment.
  • Copy existing style in nearby files for test method names and capitalization.
  • Do not leave newly-added tests commented out. All added tests should be building and passing.
  • Do not use Directory.SetCurrentDirectory in tests as it can cause side effects when tests execute concurrently.
  • Prefer using shared test service implementations (e.g., project-level TestServices/ or Helpers/ directories, or the cross-project tests/Shared/ folder) rather than creating private implementation classes within individual test files. Reusing existing test fakes and helpers keeps tests consistent, reduces duplication, and makes maintenance easier. Do not create private test classes when a shared one already exists or can be extended.
  • MTP diagnostic args (hang dump, crash dump, exit code handling) are defined in eng/Testing.targets via MtpBaseArgs. Do not hardcode these args in workflow YAML. See docs/ci/mtp-args-pipeline.md for details.
  • Use Verify (snapshot testing) for generated artifacts (files, serialized output, structured text). Prefer await Verify(value, "ext") over Assert.Contains / Assert.DoesNotContain / Assert.Equal on the same value. Run the test once to generate the .received. file, review it, then rename it to .verified. to accept it.
  • Avoid Assert.DoesNotContain as it is a weak assertion that easily goes out of date — it only proves something is absent without verifying what is present. Prefer Assert.Equal to check the entire string value, or Assert.Collection to verify the complete contents of a collection.

Running tests

(1) Build from the root with ./build.sh (~3-5 minutes). (2) If that produces errors, fix those errors and build again. Repeat until the build is successful. (3) To run tests for a specific project: dotnet test --project tests/ProjectName.Tests/ProjectName.Tests.csproj --no-build --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Note that tests for a project can be executed without first building from the root.

(4) To run specific tests, include the filter after --:

dotnet test --project tests/Aspire.Hosting.Testing.Tests/Aspire.Hosting.Testing.Tests.csproj --no-launch-profile -- --filter-method "*.TestingBuilderHasAllPropertiesFromRealBuilder" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

(5) To apply a timeout for a specific test run use --hangdump and --hangdump-timeout options after --, for example:

dotnet test --project tests/Aspire.Hosting.Testing.Tests/Aspire.Hosting.Testing.Tests.csproj --no-launch-profile -- --filter-method "*.TestingBuilderHasAllPropertiesFromRealBuilder" --hangdump --hangdump-timeout 2m

You need both options (--hangdump-timeout does not work without --hangdump). Timeout can be expressed in minutes (e.g. 3m for 3-minute timeout), or seconds (e.g. 30s for 30-seconds timeout).

Important: Avoid passing --no-build unless you have just built in the same session and there have been no code changes since. In automation or while iterating on code, omit --no-build so changes are compiled and picked up by the test run.

CRITICAL: Do NOT use VSTest-style --filter with dotnet test

This repo uses Microsoft.Testing.Platform (MTP) as the test runner, not VSTest. The classic --filter argument (before --) uses VSTest filter syntax and will hang or behave unexpectedly with MTP.

# WRONG - VSTest-style filter, will hang with MTP
dotnet test --project tests/Project.Tests/Project.Tests.csproj --filter "FullyQualifiedName~ClassName"

# CORRECT - MTP-native filters go after the -- separator
dotnet test --project tests/Project.Tests/Project.Tests.csproj --no-launch-profile -- --filter-class "*.ClassName"
dotnet test --project tests/Project.Tests/Project.Tests.csproj --no-launch-profile -- --filter-method "*.MethodName"

All test filtering must use MTP-native switches placed after --. See the filter switches listed below for the full set of options.

CRITICAL: Excluding Quarantined and Outerloop Tests

When running tests in automated environments (including Copilot agent), always exclude quarantined and outerloop tests to avoid false negatives and long-running tests:

# Correct - excludes quarantined and outerloop tests (use this in automation)
dotnet test --project tests/Project.Tests/Project.Tests.csproj --no-launch-profile -- --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

# For specific test filters, combine with quarantine and outerloop exclusion
dotnet test --project tests/Project.Tests/Project.Tests.csproj --no-launch-profile -- --filter-method "TestName" --filter-not-trait "quarantined=true" --filter-not-trait "outerloop=true"

Never run all tests without the quarantine and outerloop filters in automated environments, as this will include flaky tests that are known to fail intermittently and long-running tests that slow down CI.

Valid test filter switches include: --filter-class, --filter-not-class, --filter-method, --filter-not-method, --filter-namespace, --filter-not-namespace, --filter-not-trait, --filter-trait The switches --filter-class and --filter-method expect fully qualified names, unless a filter is used as a prefix like --filter-class "*.SomeClassName" or --filter-method "*.SomeMethodName". These switches can be repeated to run tests on multiple classes or methods at once, e.g., --filter-method "*.SomeMethodName1" --filter-method "*.SomeMethodName2".

Test Verification Commands

  • Single Test Project: Typical runtime ~10-60 seconds per test project
  • Full Test Suite: Can take 30+ minutes, use targeted testing instead

Project Layout and Architecture

Directory Structure

  • /src: Main source code for all Aspire packages
    • Aspire.Hosting/: Core hosting and orchestration infrastructure
    • Aspire.Dashboard/: Web dashboard UI (Blazor application)
    • Components/: 40+ integration packages for databases, messaging, cloud services
    • Aspire.Cli/: Command-line interface tools
  • /tests: Comprehensive test suites mirroring src structure
  • /playground: Sample applications including TestShop for verification
  • /docs: Documentation including contributing guides and area ownership
  • /eng: Build scripts, tools, and engineering infrastructure
  • /.github: CI/CD workflows, issue templates, and GitHub automation
  • /extension: VS Code extension source code

Key Configuration Files

  • global.json: Pins .NET SDK version - never modify without explicit request
  • .editorconfig: Code formatting rules, null annotations, diagnostic configurations
  • Directory.Build.props: Shared MSBuild properties across all projects
  • Directory.Packages.props: Centralized package version management
  • Aspire.slnx: Main solution file (XML-based solution format)

Continuous Integration

GitHub Actions (primary, runs on PRs)

  • tests.yml: Main test workflow running across Windows/Linux/macOS
  • tests-quarantine.yml: Runs quarantined tests separately every 6 hours
  • tests-outerloop.yml: Runs outerloop tests separately every 6 hours
  • ci.yml: Main CI workflow triggered on PRs and pushes to main/release branches
  • Build validation: Includes package generation, API compatibility checks, template validation
  • Workflow matcher maintenance: When changing CI workflow job or step names that are referenced by automation or tests, update the corresponding workflow helpers, behavior tests, and docs together. For the transient rerun workflow, keep .github/workflows/auto-rerun-transient-ci-failures.js, tests/Infrastructure.Tests/WorkflowScripts/AutoRerunTransientCiFailuresTests.cs, and docs/ci/auto-rerun-transient-ci-failures.md aligned with the live workflow YAML.
  • ⚠️ Quarantine and outerloop tests are easily broken because they primarily run on schedule, not on most PRs. Changes to tests-quarantine.yml, tests-outerloop.yml, specialized-test-runner.yml, or run-tests.yml will automatically trigger the affected workflow(s) on the PR via paths: filters. Verify the triggered runs pass before merging.

Azure DevOps (secondary, does NOT run tests on PRs)

  • eng/pipelines/azure-pipelines-public.yml: Weekly scheduled pipeline (Monday midnight UTC) that builds and runs tests on Helix
  • ⚠️ AzDO tests are easily broken because they don't run on PRs — only weekly or via manual trigger (/azp run aspire-tests)
  • Changes to test infrastructure (eng/Testing.props, eng/Testing.targets, tests/Directory.Build.*, tests/helix/*) should be validated by triggering a manual AzDO run
  • See docs/ci/azdo-public-pipeline.md for full architecture details including Helix test categories, archive process, and test routing

Dependencies and Hidden Requirements

  • Local .NET SDK: Automatically uses local SDK when available after running restore due to paths configuration in global.json
  • Package References: Centrally managed via Directory.Packages.props
  • API Surface: Public APIs tracked in src/*/api/*.cs files (auto-generated, don't edit)

Common Validation Steps

  1. Build Verification: ./build.sh should complete without errors
  2. Package Generation: ./build.sh --pack verifies all packages can be created
  3. Specific Tests: Target individual test projects related to your changes

Quarantined tests

  • Tests that are flaky and don't fail deterministically are marked with the QuarantinedTest attribute.
  • Such tests are not run as part of the regular tests workflow (tests.yml).
    • Instead they are run in the Quarantine workflow (tests-quarantine.yml).
  • A github issue url is used with the attribute
  • To reproduce or fix a flaky/quarantined test, use the fix-flaky-test skill (.agents/skills/fix-flaky-test/SKILL.md).
  • To quarantine or unquarantine a test, use the test-management skill (.agents/skills/test-management/SKILL.md).

Example: [QuarantinedTest("..issue url..")]

Quarantine/Unquarantine via GitHub Commands (Preferred)

Use these commands in any issue or PR comment. They require write access to the repository.

# Quarantine a flaky test (creates a new PR)
/quarantine-test Namespace.Type.Method https://github.com/microsoft/aspire/issues/1234

# Quarantine multiple tests at once
/quarantine-test TestMethod1 TestMethod2 https://github.com/microsoft/aspire/issues/1234

# Quarantine and push to an existing PR
/quarantine-test TestMethod https://github.com/microsoft/aspire/issues/1234 --target-pr https://github.com/microsoft/aspire/pull/5678

# Unquarantine a test (creates a new PR)
/unquarantine-test Namespace.Type.Method

# Unquarantine and push to an existing PR
/unquarantine-test TestMethod --target-pr https://github.com/microsoft/aspire/pull/5678

When you comment on a PR, the changes are automatically pushed to that PR's branch (no need for --target-pr).

Quarantine/Unquarantine via Local Tool

For local development, use the QuarantineTools directly:

# Quarantine a test
dotnet run --project tools/QuarantineTools -- -q -i https://github.com/microsoft/aspire/issues/1234 Full.Namespace.Type.Method

# Unquarantine a test
dotnet run --project tools/QuarantineTools -- -u Full.Namespace.Type.Method

Disabled tests (ActiveIssue)

  • Tests that consistently fail due to a known bug or infrastructure issue are marked with the ActiveIssue attribute.
  • These tests are completely skipped until the underlying issue is resolved.
  • Use this for tests that are blocked, not for flaky tests (use QuarantinedTest for flaky tests).

Example: [ActiveIssue("https://github.com/microsoft/aspire/issues/1234")]

Disable/Enable via GitHub Commands (Preferred)

# Disable a test due to an active issue (creates a new PR)
/disable-test Namespace.Type.Method https://github.com/microsoft/aspire/issues/1234

# Disable and push to an existing PR
/disable-test TestMethod https://github.com/microsoft/aspire/issues/1234 --target-pr https://github.com/microsoft/aspire/pull/5678

# Enable a previously disabled test (creates a new PR)
/enable-test Namespace.Type.Method

# Enable and push to an existing PR
/enable-test TestMethod --target-pr https://github.com/microsoft/aspire/pull/5678

Disable/Enable via Local Tool

# Disable a test with ActiveIssue
dotnet run --project tools/QuarantineTools -- -q -m activeissue -i https://github.com/microsoft/aspire/issues/1234 Full.Namespace.Type.Method

# Enable a test (remove ActiveIssue)
dotnet run --project tools/QuarantineTools -- -u -m activeissue Full.Namespace.Type.Method

Outerloop tests

  • Tests that are long-running, resource-intensive, or require special infrastructure are marked with the OuterloopTest attribute.
  • In this repository, always use OuterloopTest for outerloop coverage; do not replace it with Arcade's OuterLoop attribute because our CI scripts and some test projects rely on assembly-level use of the custom trait.
  • Such tests are not run as part of the regular tests workflow (tests.yml).
    • Instead they are run in the Outerloop workflow (tests-outerloop.yml).
  • An optional reason can be provided with the attribute

Example: [OuterloopTest("Long running integration test")]

Snapshot Testing with Verify

  • We use the Verify library (Verify.XunitV3) for snapshot testing in several test projects.
  • Snapshot files are stored in Snapshots directories within test projects.
  • When tests that use snapshot testing are updated and generate new output, the snapshots need to be accepted.
  • Use dotnet verify accept -y to accept all pending snapshot changes after running tests.
  • The verify tool is available globally as part of the copilot setup.

Editing resources

The *.Designer.cs files are in the repo, but are intended to match same named *.resx files. If you add/remove/change resources in a resx, make the matching changes in the *.Designer.cs file that matches that resx. The *.Designer.cs files are generated by a Visual Studio design-time tool (ResXFileCodeGenerator or PublicResXFileCodeGenerator) and there is no command-line tool to regenerate them, so they must be updated manually.

Some projects also have *.xlf (XLIFF) translation files in an xlf subdirectory next to the .resx files. After modifying a .resx file, run the following command on the affected project to update the .xlf files:

dotnet build /t:UpdateXlf <path-to-project.csproj>

Do not manually edit *.xlf files. They are updated by the UpdateXlf MSBuild target (provided by Microsoft.DotNet.XliffTasks).

Markdown files

  • Markdown files should not have multiple consecutive blank lines.
  • Code blocks should be formatted with triple backticks (```) and include the language identifier for syntax highlighting.
  • JSON code blocks should be indented properly.

Localization files

  • Files matching the pattern */localize/templatestrings.*.json are localization files. Do not translate their content. It is done by a dedicated workflow.

Trust These Instructions

These instructions are comprehensive and tested. Only search for additional information if:

  1. The instructions appear outdated or incorrect
  2. You encounter specific errors not covered here
  3. You need details about new features not yet documented

For most development tasks, following these instructions should be sufficient to build, test, and validate changes successfully.

Typescript

  • When possible, you should create Typescript files instead of Javascript files.
  • You must not use dynamic imports unless absolutely necessary. Instead, use static imports.

Aspire VS Code Extension

  • When displaying text to the user, ensure that the strings are localized. New localized strings must be put both in the extension package.nls.json and also src/loc/strings.ts.

Available Skills

The following specialized skills are available in .agents/skills/:

  • cli-e2e-testing: Guide for writing Aspire CLI end-to-end tests using Hex1b terminal automation
  • ci-test-failures: Diagnoses GitHub Actions test failures, extracts failed tests from runs, and creates or updates failing-test issues
  • code-review: Reviews a GitHub pull request for problems (bugs, security, correctness, convention violations). Use this when asked to review a PR or do a code review.
  • fix-flaky-test: Reproduces and fixes flaky/quarantined tests using the CI reproduce workflow (reproduce-flaky-tests.yml). Use this when investigating, reproducing, or fixing a flaky or quarantined test.
  • cli-channel-debugging: Emulates any Aspire CLI build identity (channel/version/commit/package source) from a locally built CLI via ASPIRE_CLI_* env vars or the install sidecar, to reproduce and fix channel/version-specific bugs locally. Use when asked to simulate a daily/staging/stable/PR build or decide which override knobs to set.
  • dashboard-testing: Guide for writing tests for the Aspire Dashboard using xUnit and bUnit
  • test-management: Quarantines or disables flaky/problematic tests using the QuarantineTools utility
  • connection-properties: Expert for creating and improving Connection Properties in Aspire resources
  • dependency-update: Guides dependency version updates by checking nuget.org, triggering the dotnet-migrate-package Azure DevOps pipeline, and monitoring runs
  • api-review: Reviews .NET API surface area PRs for design guideline violations, applies rules from .NET Framework Design Guidelines and Aspire conventions, and attributes findings to the author who introduced each API
  • backport-pr: Triggers the /backport bot on a source PR, waits for the bot-created backport PR, and fills in the shiproom template (Customer Impact, Testing, Risk, Regression?). Use when backporting a fix to a release branch.
  • azdo-internal: Triggers, monitors, and validates changes to the Aspire internal Azure DevOps pipeline (microsoft-aspire, definition 1602) on dnceng/internal. Use when asked to trigger an internal/AzDO build, check build status, push to the internal mirror, or validate eng/ pipeline changes.
  • startup-perf: Measures Aspire startup profiling with CLI self-profile capture and dashboard export traces
  • reviewing-aspire-architecture: Use only when explicitly asked for deep architectural or pattern review of an existing PR or diff, or for a concrete Aspire-domain question escalated by a generic reviewer that cannot resolve it. Do not use for design or explanation requests, ordinary reviews, or based on changed file paths.
  • vscode-extension: Guide for developing, building, testing, and debugging the Aspire VS Code extension under extension/. Use when investigating an issue in, debugging, or working on a feature for the VS Code extension.
  • deprecate-integration: Soft-sunsets a shipped hosting integration: marks its API [Obsolete], adds a README warning, hides the package from aspire add, removes integration-specific automation, suppresses the resulting warnings in first-party consumers, and ships one final obsolete release. Use when deprecating, sunsetting, or retiring an integration.

Pattern-Based Instructions

Additional instructions are automatically applied when editing files matching specific patterns:

PatternInstructions File
src/**/*.cs.github/instructions/xmldoc.instructions.md - XML documentation standards
src/Aspire.Hosting/**/*.cs.github/instructions/hosting-core.instructions.md - Hosting core review patterns
src/Aspire.Hosting.Azure*/**/*.cs.github/instructions/hosting-azure.instructions.md - Hosting Azure review patterns
src/Aspire.Dashboard/**/*.{cs,razor,js}.github/instructions/dashboard.instructions.md - Dashboard review patterns
src/Components/**/*.cs.github/instructions/components.instructions.md - Client integration review patterns
src/Aspire.Hosting*/README.md.github/instructions/hosting-readme.instructions.md - Hosting integration READMEs
src/Components/**/README.md.github/instructions/client-readme.instructions.md - Client integration READMEs
tools/QuarantineTools/*.github/instructions/quarantine.instructions.md - QuarantineTools usage
tests/**/*.cs.github/instructions/test-review-guidelines.instructions.md - Flaky test patterns and test review guidelines
eng/scripts/get-aspire-cli*.sh, eng/scripts/get-aspire-cli*.ps1.github/instructions/acquisition-tests.instructions.md - CLI acquisition script tests

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.