Conversation
…ources - Created new IResourceWithCanCopyContainerFiles interface to mark resources that can consume container files - Updated ProjectResource to implement IResourceWithCanCopyContainerFiles - Updated PythonAppResource to implement IResourceWithCanCopyContainerFiles - Updated YarpResource to implement IResourceWithCanCopyContainerFiles - Updated PublishWithContainerFiles method to constrain to IResourceWithCanCopyContainerFiles - Added AddContainerFiles support to NodeAppResource dockerfile generation Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
Added test to verify that NodeAppResource correctly includes container files when generating Dockerfiles during publish Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
…erFiles - JavaScriptAppResource now implements IResourceWithCanCopyContainerFiles - Updated test to use proper PublishWithContainerFiles API instead of manually adding annotations - This provides better type safety and consistency with the API design Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
@copilot Revert all changes under Aspire.ProjectTemplates |
…dd pipeline config to NodeApp - Reverted all Aspire.ProjectTemplates localization files to original state - Created public experimental AddContainerFiles extension method for DockerfileStage - Removed private AddContainerFiles implementations from JavaScript and Python - Added pipeline configuration to NodeAppResource to order build steps correctly - Added ASPIREPIPELINES001 pragma and Pipelines namespace to JavaScript extensions Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
@copilot Revert all changes under Aspire.ProjectTemplates |
…ling - Updated YarpResourceExtensions.EnsurePublishWithStaticFilesDockerFileBuilder to use public AddContainerFiles API - Removed duplicate container files logic from Yarp - Updated AddContainerFiles to silently skip sources without container image names (no exceptions) - Updated XML documentation to reflect graceful handling behavior - Removed unnecessary Microsoft.Extensions.Logging using directive - Updated Yarp test snapshots to reflect new Dockerfile format with extra blank line - All tests passing (35 Yarp, 9 NodeApp, 2 Python) Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
|
@copilot Revert the changes under Aspire.ProjectTemplates they are in here again |
Remove all ProjectTemplates localization file changes that were inadvertently included in commit 09be3e4. These files are unrelated to the container files feature. Co-authored-by: davidfowl <95136+davidfowl@users.noreply.github.com>
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a new interface IResourceWithCanCopyContainerFiles to better differentiate between resources that produce container files and those that can consume/copy container files from other resources. The changes include:
- Introduction of the
IResourceWithCanCopyContainerFilesinterface to mark resources that can receive container files - Refactoring of the
PublishWithContainerFilesmethod to use the new interface constraint - Implementation of the new interface on resources like
YarpResource,PythonAppResource,JavaScriptAppResource, andProjectResource - Extraction of
AddContainerFilesmethod into a shared extension class (DockerfileStageExtensions) - Changes to error handling: removed warnings and exceptions for missing container image names, now silently skipping instead
- Addition of pipeline configuration for Node.js apps to ensure container file sources are built first
- Updates to snapshot test files (adding trailing newlines to Dockerfiles)
- Updates to localization files for new MCP endpoint parameters (not directly related to container files)
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
IResourceWithCanCopyContainerFiles.cs |
New interface defining resources that can consume container files from other resources |
DockerfileStageExtensions.cs |
New shared extension method for adding container file COPY statements to Dockerfile stages |
ResourceBuilderExtensions.cs |
Updated PublishWithContainerFiles to constrain to IResourceWithCanCopyContainerFiles |
YarpResource.cs |
Implements IResourceWithCanCopyContainerFiles |
YarpResourceExtensions.cs |
Refactored to use shared AddContainerFiles extension, removed logging |
PythonAppResource.cs |
Implements IResourceWithCanCopyContainerFiles |
PythonAppResourceBuilderExtensions.cs |
Removed local AddContainerFiles method (now using shared extension) |
JavaScriptAppResource.cs |
Implements IResourceWithCanCopyContainerFiles |
JavaScriptHostingExtensions.cs |
Uses shared AddContainerFiles and adds pipeline dependency configuration |
ProjectResource.cs |
Implements IResourceWithCanCopyContainerFiles |
AddNodeAppTests.cs |
New test verifying NodeApp Dockerfile generation with container files |
| Snapshot files (4 files) | Updated snapshots with trailing newlines in Dockerfiles |
| Localization files (48 files) | Added English descriptions for new MCP endpoint parameters (untranslated in non-English files) |
| /// </code> | ||
| /// </example> | ||
| [Experimental("ASPIREDOCKERFILEBUILDER001", UrlFormat = "https://aka.ms/aspire/diagnostics/{0}")] | ||
| public static DockerfileStage AddContainerFiles(this DockerfileStage stage, IResource resource, string rootDestinationPath) |
There was a problem hiding this comment.
The <summary> tag should start with a verb. Change 'Adds COPY --from statements' to match the standard pattern of starting with an action verb. The current phrasing is acceptable, but for consistency with other methods in the codebase, consider: 'Adds COPY --from statements to the Dockerfile stage for container files from resources referenced by <see cref="ContainerFilesDestinationAnnotation"/>.'
| /// <para> | ||
| /// For each annotation: | ||
| /// <list type="bullet"> | ||
| /// <item>If the source resource has a container image name (via <c>TryGetContainerImageName</c>), COPY statements are generated</item> |
There was a problem hiding this comment.
[nitpick] The documentation mentions using <c>TryGetContainerImageName</c>, but should use <see cref=\"\"/> for proper API cross-referencing. However, this method appears to be an extension method that may not be in the current namespace. If it's a valid API reference, change to: <see cref=\"TryGetContainerImageName\"/>. If it's not accessible for cref, the current <c> tag is acceptable.
| /// <item>If the source resource has a container image name (via <c>TryGetContainerImageName</c>), COPY statements are generated</item> | |
| /// <item>If the source resource has a container image name (via <see cref="TryGetContainerImageName"/>), COPY statements are generated</item> |
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 12699Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 12699" |
src/Aspire.Hosting/ApplicationModel/IResourceWithCanCopyContainerFiles.cs
Outdated
Show resolved
Hide resolved
…mentation to NodeAppResource - Renamed IResourceWithCanCopyContainerFiles to IContainerFilesDestinationResource for better clarity - Removed IContainerFilesDestinationResource from JavaScriptAppResource - Added IContainerFilesDestinationResource to NodeAppResource only - Updated Yarp AddContainerFiles to use /app/wwwroot as root destination path - Updated all references across ProjectResource, PythonAppResource, YarpResource, and NodeAppResource - All tests passing (35 Yarp, 9 NodeApp, 2 Python) Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
Remove ProjectTemplates localization files that were inadvertently re-added in the previous commit. Co-authored-by: eerhardt <8291187+eerhardt@users.noreply.github.com>
|
/backport to release/13.0 |
|
Started backporting to release/13.0: https://github.com/dotnet/aspire/actions/runs/19119825190 |
Implementation Complete ✅
Changes Made
1. Properly Reverted ProjectTemplates Changes
src/Aspire.ProjectTemplates/now properly reverted to original state2. Interface Renamed and Implementation Moved
IResourceWithCanCopyContainerFilestoIContainerFilesDestinationResourcefor better clarityJavaScriptAppResourcetoNodeAppResourceonly3. Public Experimental API for AddContainerFiles
DockerfileStageExtensions.AddContainerFiles()as a public experimental API[Experimental("ASPIREDOCKERFILEBUILDER001")]src/Aspire.Hosting/ApplicationModel/Docker/DockerfileStageExtensions.cs4. Reused AddContainerFiles Across All Resources
EnsurePublishWithStaticFilesDockerFileBuilder/app/wwwrootas the root destination path for container files (not just/app)5. Pipeline Configuration for NodeAppResource
WithPipelineConfigurationto ensure container file sources are built before NodeAppPublishWithContainerFilesSummary of All Changes
New Interface:
IContainerFilesDestinationResource(renamed fromIResourceWithCanCopyContainerFiles)ProjectResource,PythonAppResource,YarpResource, andNodeAppResource(not JavaScriptAppResource)Updated Extension Method:
PublishWithContainerFiles<T>T : IContainerFilesDestinationResourcefor type safetyPublic Experimental API:
DockerfileStage.AddContainerFiles()NodeApp & Yarp Container Files Support:
AddContainerFiles()/app/wwwrootas the destinationTests Passed
Benefits
IContainerFilesDestinationResourcemore clearly describes the intentOriginal prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.