Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13168Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13168" |
…ence Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
…ort allocation - Changed app URLs from 18001/18002 to 16179/16180 (standard app port range) - Updated OTLP endpoints from 18003/18005 to 17119/17120 (standard OTLP range) - Added MCP endpoints 18036/18037 (standard MCP range) - Updated Resource Service endpoints to match OTLP endpoints - Removed launchBrowser from generate-manifest profile for consistency Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
- Removed DotnetToolInstaller.cs (leftover from dotnet tool install approach) - Created new test project Aspire.Hosting.DotnetTool.Tests with 22 tests - All tests pass and validate AddDotnetTool extension methods - Tests cover: basic usage, version specs, prerelease, custom sources, args, and manifest generation - Added using statements to playground files (needed for test linking) - Fixed DotnetToolResource to use "." as working directory (fixes manifest generation) - Added test project to solution file in alphabetical order Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Updated `ResourceSnapshotBuilder` to not override any custom resource types a consumer may have set. Updated `ApplicationOrchestrator` to also not set the resource type - we don't need two places in Aspire core setting the ResourceType
The implementation works, but isnt' great as it fights with DCP a lot.
| x.Args.Add("--"); | ||
| } | ||
|
|
||
| static async Task StartSourceFixer(T resource, InitializeResourceEvent evt, CancellationToken ct) |
There was a problem hiding this comment.
This method is a hack and a half.
To make the source column show just the tool args, and not the internals of the dotnet command run, we need to set KnownProperties.Executable.Path and KnownProperties.Resource.AppArgs. The latter in turn also requires messing with KnownProperties.Resource.AppArgsSensitivity to ensure secrets are properly redacted.
However dcp will continually overwrite those properties every time an update occurs, so we need to respond to those and restore our values.
aspire/src/Aspire.Hosting/Dcp/ResourceSnapshotBuilder.cs
Lines 184 to 203 in 9c9755a
So this method tries to respond to any update from DCP, and undo DCP's changes.
…ate`, without actually updating anything.
- Ensure tool source renders nicely before a resource starts - Add a property including the raw args to `dotnet tool exec` to help with troubleshooting if needed.
Enhances Aspire to treat dotnet tool resources as first-class citizens. - Adds KnownResourceTypes.Tool and updates DotnetToolResource to use it. - Sets tool package ID as the resource "Source" for dashboard clarity. - Adds IsTool and TryGetToolPackage extensions for resource model. - Updates dashboard to display tool package as source. - Refines argument handling: only tool-specific args are shown in dashboard, full args used for execution. - Refactors DotnetToolResourceExtensions and removes dashboard update workaround. - Removed unused `IResourceAnnotation` from AppLaunchArgumentAnnotation. - Adds and updates tests for tool resource handling. - Improves diagnostics with DebuggerDisplay and code cleanups.
There was a problem hiding this comment.
Pull request overview
This PR introduces experimental support for .NET tool resources in Aspire, allowing developers to run .NET global tools (like dotnet-ef, dotnet-dump, etc.) as Aspire resources using dotnet tool exec. This feature addresses the need for tool acquisition and execution without manual installation steps, building on the existing ExecutableResource infrastructure.
Key Changes:
- New
DotnetToolResourceandDotnetToolAnnotationtypes for representing .NET tools as first-class resources - Extension methods for configuring tool version, prerelease support, custom NuGet sources, and feed behavior
- Dashboard integration showing tools with a dedicated resource type and custom "Source" column display
- Comprehensive test coverage including unit tests and functional tests
Reviewed changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 20 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Aspire.Hosting/ApplicationModel/DotnetToolResource.cs | New resource class representing .NET tool resources, inheriting from ExecutableResource |
| src/Aspire.Hosting/ApplicationModel/DotnetToolAnnotation.cs | New annotation class containing tool configuration (package ID, version, sources, flags) |
| src/Aspire.Hosting/DotnetToolResourceExtensions.cs | Extension methods for adding and configuring .NET tool resources with fluent API |
| src/Aspire.Hosting/Dcp/DcpExecutor.cs | Modified argument handling to distinguish between executable args and display args for tools |
| src/Aspire.Hosting/Dcp/ResourceSnapshotBuilder.cs | Updated to preserve ResourceType set via WithInitialState instead of overwriting |
| src/Aspire.Hosting/Orchestrator/ApplicationOrchestrator.cs | Removed ResourceType assignments as it's now set earlier via WithInitialState |
| src/Aspire.Hosting/ApplicationModel/AppLaunchArgumentAnnotation.cs | Removed IResourceAnnotation interface (internal implementation detail) |
| src/Shared/Model/KnownResourceTypes.cs | Added "Tool" resource type constant |
| src/Shared/Model/KnownProperties.cs | Added tool-specific properties (Package, Version, ExecArgs) |
| src/Aspire.Dashboard/Model/ResourceViewModelExtensions.cs | Added IsTool() and TryGetToolPackage() extension methods |
| src/Aspire.Dashboard/Model/ResourceSourceViewModel.cs | Updated source display logic to show tool package name in Source column |
| tests/Aspire.Hosting.DotnetTool.Tests/AddDotnetToolTests.cs | Comprehensive unit tests covering all configuration options and manifest generation |
| tests/Aspire.Hosting.DotnetTool.Tests/DotnetToolFunctionalTests.cs.cs | Functional tests verifying tool execution with successful and failed scenarios |
| tests/Aspire.Hosting.Tests/Dcp/DcpExecutorTests.cs | Added test for tool argument handling in DCP executor |
| tests/Aspire.Hosting.DotnetTool.Tests/Aspire.Hosting.DotnetTool.Tests.csproj | New test project for .NET tool resource tests |
| playground/DotnetTool/DotnetTool.AppHost/* | Sample AppHost demonstrating various tool configurations and edge cases |
| Aspire.slnx | Added references for new test project and playground app |
tests/Aspire.Hosting.DotnetTool.Tests/DotnetToolFunctionalTests.cs.cs
Outdated
Show resolved
Hide resolved
| /// <summary> | ||
| /// Adds a .NET tool resource to the distributed application builder. | ||
| /// </summary> | ||
| /// <param name="builder">The <see cref="IDistributedApplicationBuilder"/>.</param> | ||
| /// <param name="name">The name of the resource.</param> | ||
| /// <param name="packageId">The package id of the tool.</param> | ||
| /// <returns>The <see cref="IResourceBuilder{T}"/>.</returns> |
There was a problem hiding this comment.
According to the XML documentation guidelines, public API extension methods should include an example showing practical usage. Consider adding an example section showing how to use AddDotnetTool.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
davidfowl
left a comment
There was a problem hiding this comment.
LGTM - clean implementation following Aspire patterns. Experimental flag is appropriate for new API.
|
Thanks for the contribution! This is a great addition to Aspire. 🎉 |
Description
This Pr contains a
dotnet toolresource type, currently marked as experimental. (Based on my initial work, and some of copilots work from #13169.).Fixes #13077
It builds upon the Executable resource ultimately calling into
dotnet tool exec- similar to howProjectResourcebuilds on top of ExecutableResource, and callsdotnet runordotnet watch. Although I've avoided teaching dcp or the application orchestrator anything specific about dotnet tools.Basic Use:
With some helper methods on the resource builder for arguments on
dotnet tool execWhich are just wrappers over the
DotnetToolAnnotationattached to the resource.The resource sets custom resource properties so the dashboard renders the

Sourcecolumn for tools more natively, without focusing on the implementation details ofdotnet tool execWithout:
After:

Tool have a dedicated resource type, so you can filter to just tools

And also includes some tool specific properties. (Although these are only visible by choosing "show all properties"

Limitations / Known Issues
global.jsonfile forcing an older sdk version.Checklist
<remarks />and<code />elements on your triple slash comments?doc-ideatemplatebreaking-changetemplatediagnostictemplate