Conversation
…re specific asset share a target path Fixes dotnet#54779 A MAUI Blazor Hybrid app that references a Razor class library and the Microsoft.AspNetCore.Components.WebView (BlazorWebView) package fails to build in Preview 6 with: GenerateStaticWebAssetEndpointsManifest ... Sequence contains more than one element Three assets map to the same target path "_framework/blazor#[.{fingerprint}]?.modules.json": * an `All` asset from the BlazorWebView package, * an `All` project *build* JS modules manifest, and * (new in Preview 6) a `Publish` project *publish* JS modules manifest. ChooseNearestAssetKind surfaced the "two `All` assets" ambiguity eagerly (yielding both and breaking) before it reached the more specific `Publish` asset, so SingleOrDefault() threw. The task itself is unchanged; the new publish manifest changed the input. Defer the multi-`All` decision: track up to two `All` candidates and only surface them (so callers can still error on genuine ambiguity) when no more specific Build/Publish asset exists in the group. A specific asset that appears after the `All` assets now correctly wins. This also fixes the identical latent path in GenerateStaticWebAssetsDevelopmentManifest, the only other caller of ChooseNearestAssetKind. Adds a regression test reproducing the exact asset group; it throws before the fix and passes after. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.
Fixes #54779
Regression (Preview 6)
A MAUI Blazor Hybrid app that references a Razor class library and the
Microsoft.AspNetCore.Components.WebView(BlazorWebView) package fails to build with:Root cause
Three static web assets map to the same target path
_framework/blazor#[.{fingerprint}]?.modules.json:Allasset coming from the BlazorWebView package,Allproject build JS-modules manifest, andPublishproject publish JS-modules manifest.StaticWebAsset.ChooseNearestAssetKindsurfaced the "twoAllassets" ambiguity eagerly (ityielded both andbreaked) before it ever reached the more specificPublishasset, so the consumer'sSingleOrDefault()threw.GenerateStaticWebAssetEndpointsManifestitself is unchanged — the new publish manifest changed the input to it.Fix
Defer the multi-
Alldecision: track up to twoAllcandidates and only surface them (so the caller can still error on a genuine ambiguity) when no more specific Build/Publish asset is present in the group. A more specific asset that appears after theAllassets now correctly wins. This also fixes the identical latent path inGenerateStaticWebAssetsDevelopmentManifest— the only other caller ofChooseNearestAssetKind.Testing
GeneratesPublishManifest_WhenAllAndPublishAssetsShareTargetPath_PrefersPublishAsset, which reconstructs the exact 3-asset group. It throwsSequence contains more than one elementbefore the fix and passes after, producing a single endpoint sourced from the publish manifest.GenerateStaticWebAssetEndpointsManifestTest(5),GenerateStaticWebAssetsDevelopmentManifestTest(23), andGenerateStaticWebAssetsManifestTest(19) all still pass.