Clear AssetGroups on framework assets at P2P project boundaries#54049
Open
Clear AssetGroups on framework assets at P2P project boundaries#54049
AssetGroups on framework assets at P2P project boundaries#54049Conversation
Copilot created this pull request from a session on behalf of
javiercn
April 22, 2026 21:41
View session
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a Static Web Assets transitive behavior issue where framework assets (SourceType=Framework) incorrectly retain AssetGroups metadata across P2P boundaries, causing downstream group filtering to exclude those assets (runtime 404s).
Changes:
- Clear
AssetGroupsfor framework static web assets duringComputeReferenceStaticWebAssetItemsexecution (both single-asset and grouped-asset paths). - Add unit tests to verify
AssetGroupsclearing for framework assets and preservation for non-framework assets. - Extend the test helper
CreateCandidateto allow specifyingAssetGroups.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/StaticWebAssetsSdk/Tasks/ComputeReferenceStaticWebAssetItems.cs | Adds ClearAssetGroupsIfFramework and calls it when producing referenced static web assets. |
| test/Microsoft.NET.Sdk.StaticWebAssets.Tests/StaticWebAssets/ComputeReferenceStaticWebAssetItemsTest.cs | Adds tests covering AssetGroups clearing behavior and updates the asset factory to set AssetGroups. |
Comments suppressed due to low confidence (1)
src/StaticWebAssetsSdk/Tasks/ComputeReferenceStaticWebAssetItems.cs:66
- In the grouped-assets branch, the decision to allow multiple assets to coexist at the same target path is based on
AllAssetsHaveDistinctGroups(all, ...)beforeClearAssetGroupsIfFrameworkruns. ClearingAssetGroupsafterward can break that invariant (e.g., a framework asset becomes ungrouped while another asset at the same path keeps a non-empty group), which can later fail manifest validation (StaticWebAsset.ValidateAssetGrouptreats multipleAllassets at the same path without distinct non-empty groups as a conflict). Consider clearingAssetGroupsbefore the distinct-groups check and then re-evaluating selection/coexistence (or skipping group-clearing when there are multiple assets for a target path and returning a deterministic single selection / explicit error).
// If all assets have distinct, non-empty AssetGroups, they can coexist
if (StaticWebAsset.AllAssetsHaveDistinctGroups(all, groupSet))
{
foreach (var groupedAsset in all)
{
if (ShouldIncludeAssetAsReference(groupedAsset, out var groupReason))
{
if (UpdateSourceType && !StaticWebAsset.SourceTypes.IsFramework(groupedAsset.SourceType))
{
groupedAsset.SourceType = StaticWebAsset.SourceTypes.Project;
}
ClearAssetGroupsIfFramework(groupedAsset);
if (MakeReferencedAssetOriginalItemSpecAbsolute)
{
groupedAsset.OriginalItemSpec = Path.GetFullPath(groupedAsset.OriginalItemSpec);
}
Contributor
|
Thanks for your PR, @@copilot. |
maraf
approved these changes
Apr 23, 2026
f3b0923 to
82d3f76
Compare
20fccc8 to
5d9249f
Compare
- Extract shared MaterializeFrameworkAsset helper to StaticWebAsset - Extract shared RemapEndpointRoute helper to StaticWebAssetEndpoint - UpdateExternallyDefinedStaticWebAssets materializes Framework assets from P2P references using shared helpers - UpdatePackageStaticWebAssets uses same shared helpers for NuGet path - ComputeReferenceStaticWebAssetItems applies FrameworkPattern glob to mark matching Discovered assets as Framework - Endpoint route remapping strips old library BasePath from routes and applies consumer's BasePath, including label property remapping - OriginalFrameworkEndpoints output for correct Remove/Include contract - RelatedAsset remapping for compressed assets during materialization - Unit tests for materialization, pass-through, and route remapping - P2P integration tests validating end-to-end framework asset flow Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…s clearing from ComputeReferenceStaticWebAssetItems to MaterializeFrameworkAsset, and reorder UpdateExternallyDefinedStaticWebAssets to run FilterByGroup before materialization. This prevents group-tagged framework assets (e.g. BlazorWebAssembly) from being materialized at consuming projects that don't declare acceptance of those groups.
5d9249f to
71fd32f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ApplyStaticWebAssetFrameworkPatternthat applies glob patterns to update matchingSourceType=Discoveredassets toSourceType=FrameworkResolveProjectStaticWebAssetsafterDefineStaticWebAssetswhenStaticWebAssetFrameworkPatternis setMaterializeProjectReferenceFrameworkAssetsto materialize P2P framework assets at build timeFrameworkAssetsP2PConsumerfor integration testingApplyStaticWebAssetFrameworkPattern(9 tests pass)Skipparameter instead of commented-out code