Repository navigation
Make required command validation generic via resource annotations for orchestrator pre-checks - #11944
Conversation
Co-authored-by: davidfowl <[email protected]>
Co-authored-by: davidfowl <[email protected]>
Co-authored-by: davidfowl <[email protected]>
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 11944Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 11944" |
|
Copilot fix the build failures, I see this error: |
Co-authored-by: DamianEdwards <[email protected]>
... Fixed the build failures. Removed the extra blank line in Commit: 5f2c8d9 |
Co-authored-by: DamianEdwards <[email protected]>
…tion-generic-resource-annotations
…tion-generic-resource-annotations
Convert Python to work against the new feature.
🎬 CLI E2E Test RecordingsThe following terminal recordings are available for commit
📹 Recordings uploaded automatically from CI run #21490341442 |
Update Azure Functions to use the new feature.
Refactor devtunnel CLI validation to use generic callback Replaces DevTunnelCliInstallationManager with a callback-based version validation using RequiredCommandValidator. Updates resource startup logic to use the new approach, improves RequiredCommandValidationResult, and removes obsolete tests. Adds new targeted tests for CLI version validation. Cleans up project file references. This makes CLI validation more modular, testable, and consistent.
Add more tests. Adjust namespaces. Revert unnecessary changes.
There was a problem hiding this comment.
Pull request overview
This pull request introduces a unified, annotation-based system for validating required commands/executables before resources start. It replaces resource-specific validation classes with a declarative approach using RequiredCommandAnnotation and WithRequiredCommand extension methods, processed automatically by a new lifecycle hook integrated into the orchestrator.
Changes:
- Introduced
RequiredCommandAnnotation,RequiredCommandValidationContext,RequiredCommandValidationResult,IRequiredCommandValidator, andRequiredCommandValidationLifecycleHookto provide a generic, reusable validation infrastructure - Removed legacy validators (
FuncCoreToolsInstallationManager,DevTunnelCliInstallationManager,PythonInstallationManager,UvInstallationManager) and base class (RequiredCommandValidatorin Shared) - Migrated Azure Functions, DevTunnels, JavaScript, and Python resource extensions to use the new annotation-based system
- Added comprehensive test coverage for the new system and updated existing tests
Reviewed changes
Copilot reviewed 55 out of 58 changed files in this pull request and generated 12 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/ApplicationModel/RequiredCommandAnnotation.cs | New annotation class for declaring required commands on resources |
| src/Aspire.Hosting/ApplicationModel/RequiredCommandValidationContext.cs | Context object passed to validation callbacks |
| src/Aspire.Hosting/ApplicationModel/RequiredCommandValidationResult.cs | Result type for validation operations |
| src/Aspire.Hosting/ApplicationModel/IRequiredCommandValidator.cs | Interface for command validation service |
| src/Aspire.Hosting/ApplicationModel/RequiredCommandValidator.cs | Default implementation of command validation with coalescing |
| src/Aspire.Hosting/Lifecycle/RequiredCommandValidationLifecycleHook.cs | Lifecycle hook that validates commands before resource start |
| src/Aspire.Hosting/RequiredCommandResourceExtensions.cs | Extension methods for adding required command annotations |
| src/Aspire.Hosting/DistributedApplicationBuilder.cs | Registers the new validation services and lifecycle hook |
| src/Aspire.Hosting.Azure.Functions/AzureFunctionsProjectResourceExtensions.cs | Migrated to use WithRequiredCommand for "func" |
| src/Aspire.Hosting.DevTunnels/DevTunnelResourceBuilderExtensions.cs | Migrated to use new validation system with custom version checking |
| src/Aspire.Hosting.JavaScript/JavaScriptHostingExtensions.cs | Added WithRequiredCommand for node, npm, bun, yarn, pnpm |
| src/Aspire.Hosting.Python/PythonAppResourceBuilderExtensions.cs | Migrated to use WithRequiredCommand for python and uv |
| tests/Aspire.Hosting.Tests/RequiredCommandAnnotationTests.cs | New comprehensive test suite for the annotation system |
| tests/Aspire.Hosting.Tests/PathLookupHelperTests.cs | Tests for PATH lookup helper functionality |
| Localization files | Added new message strings for validation errors |
Files not reviewed (2)
- src/Aspire.Hosting.DevTunnels/Resources/MessageStrings.Designer.cs: Language not supported
- src/Aspire.Hosting/Resources/MessageStrings.Designer.cs: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Damian Edwards (DamianEdwards)
left a comment
There was a problem hiding this comment.
I verified locally with Copliot CLI (see command above) and all seems to be good!


This pull request introduces a new, unified system for validating required commands/executables for resources using the
RequiredCommandAnnotationandWithRequiredCommandextension methods. It removes legacy, resource-specific command validation classes and migrates all relevant code to use the new declarative approach. This results in a more flexible, reusable, and maintainable validation mechanism across the codebase. Additionally, documentation has been added to explain the new system, and JavaScript and Azure Functions resource extensions have been updated to utilize it.Key changes:
Removal of Legacy Validators
FuncCoreToolsInstallationManagerandDevTunnelCliInstallationManagerclasses, along with their registrations and usages, in favor of the new annotation-based system. [1] [2] [3] [4]RequiredCommandValidator.csin both Azure Functions and DevTunnels projects. [1] [2]Migration to RequiredCommandAnnotation
WithRequiredCommand("func", ...)instead of the previous installation manager for validating Azure Functions Core Tools. [1] [2]RequiredCommandAnnotationwith a version validation callback for the devtunnel CLI, replacing the previous installation manager logic. [1] [2]JavaScript Resource Improvements
node,npm,bun,yarn) usingWithRequiredCommand, providing appropriate installation help links for each. [1] [2] [3] [4]These changes make command validation more consistent, extensible, and easier to maintain across all resource types.
Fix #11943