Summary
In SDK 11.0.100-preview.6.26313.102, building or publishing a .NET MAUI app that uses BlazorWebView and references a Razor Class Library fails on multiple TFMs (Windows AND Apple) with:
error : InvalidOperationException: Sequence contains more than one element
at System.Linq.ThrowHelper.ThrowMoreThanOneElementException()
at System.Linq.Enumerable.SingleOrDefault[TSource](IEnumerable`1 source)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetEndpointsManifest
.ComputeManifestAssets(IEnumerable`1 assets, String kind)+MoveNext()
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
at Microsoft.AspNetCore.StaticWebAssets.Tasks.GenerateStaticWebAssetEndpointsManifest.Execute()
The same project builds and publishes cleanly on SDK 11.0.100-preview.5.26256.105.
Environment
|
|
| Failing SDK |
11.0.100-preview.6.26313.102 |
| Last good SDK |
11.0.100-preview.5.26256.105 |
| OS |
Reproduces on both Windows and macOS CI hosted images |
| TFMs affected |
net11.0-windows10.0.19041.0, net11.0-windows10.0.20348.0, net11.0-maccatalyst, net11.0-ios (any TFM where the BlazorWebView package targets are imported) |
| Failing CI jobs (PR #35364, build 1463118) |
Build Windows (Debug), Build Windows (Release), Build macOS (Release), Samples windows (integration test) |
| Project SDK |
Microsoft.NET.Sdk.Razor |
| Target |
GenerateStaticWebAssetsPublishManifest |
| Task |
GenerateStaticWebAssetEndpointsManifest |
| Targets file |
.dotnet\sdk\11.0.100-preview.6.26313.102\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Publish.targets(55,5) |
Repro shape
A MAUI Hybrid app csproj (<Project Sdk="Microsoft.NET.Sdk.Razor">) that:
- Has Razor components and a
wwwroot/ folder with at least one Maui.Controls.Sample.lib.module.js plus a css/app.css.
- ProjectReferences a Razor Class Library (
MauiRazorClassLibrarySample.csproj) that also has wwwroot/ content and scoped CSS.
- ProjectReferences the BlazorWebView package (
Microsoft.AspNetCore.Components.WebView.Maui) — preview.6 SDK assemblies for that package include a _framework/blazor.modules.json static web asset.
The full failing project is publicly available: src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csproj on the .NET MAUI net11.0 branch.
Root cause (from inspecting the binlog)
Three distinct StaticWebAssetEndpoint items collide on the same Route='_framework/blazor.modules.json':
| # |
Source kind |
AssetFile (paths abbreviated) |
| 1 |
Package (All) |
.packages\microsoft.aspnetcore.components.webview\11.0.0-preview.6.26313.102\staticwebassets\blazor.modules.json |
| 2 |
Build |
artifacts\obj\Maui.Controls.Sample\Release\net11.0-windows10.0.20348.0\win-x64\jsmodules\jsmodules.build.manifest.json |
| 3 |
Publish |
artifacts\obj\Maui.Controls.Sample\Release\net11.0-windows10.0.20348.0\win-x64\jsmodules\jsmodules.publish.manifest.json |
Asset #3 (note the .publish. segment in the path) appears to be new in preview.6 — preview.5 only produced jsmodules.build.manifest.json.
Looking at the failing code in src/StaticWebAssetsSdk/Tasks/GenerateStaticWebAssetEndpointsManifest.cs:
foreach (var group in assetsByTargetPath)
{
var asset = StaticWebAsset.ChooseNearestAssetKind(group, kind).SingleOrDefault(); // 💥 throws here
...
}
ChooseNearestAssetKind(group, "Publish") is returning >1 asset for the _framework/blazor.modules.json group, and SingleOrDefault() rejects it. The same pattern repeats for several _content/MauiRazorClassLibrarySample/* routes where the raw asset, the .gz compressed asset, and the .br publish-compressed asset collide under the same target path.
Likely culprit
The behavior change in preview.6 is consistent with #54353 — Add support for materializing framework static web assets at project-to-project reference boundaries (merged 2026-05-18). That PR changes how framework assets from package references flow across P2P boundaries, which is exactly the boundary being crossed in this scenario (Razor app → Razor class library → BlazorWebView package).
I haven't bisected to confirm — happy to do so if useful.
Reproduction
The simplest public repro is to run dotnet build on a checkout of the .NET MAUI net11.0 branch with SDK 11.0.100-preview.6.26313.102. The Build Windows jobs of any maui-pr build on dotnet/maui PR #35364 (which bumps SDK from preview.5 → preview.6) fail with this exception; the corresponding stage on the net11.0 branch (still on preview.5) is green.
Reference failing build: Azure DevOps 1463118, job Build Windows (Release). Binlog is from that build; happy to attach (or grab from the AzDO Windows_NT_Build Windows (Release)_Attempt1 artifact).
Expected behavior
The Publish manifest generation should disambiguate Build-kind, Publish-kind, and All-kind assets that map to the same target route, producing exactly one chosen asset per route per manifest kind — not throwing.
Workaround on consumer side?
Not aware of a clean opt-out. Removing the MauiRazorClassLibrarySample ProjectReference avoids the failure but is not a real solution. Suggestions welcome.
Related prior art
- #50183 — same
SingleOrDefault exception in the sibling GenerateStaticWebAssetsDevelopmentManifest class; root cause was also two assets collapsing to the same target path.
- #52281 —
[StaticWebAssets] Fix duplicate asset detection in GroupAssetsByTargetPath (Dec 2025).
- #53305 —
Handle duplicate static web asset identities gracefully (Mar 2026).
- #54353 — likely culprit; introduces P2P framework asset materialization.
cc @javiercn @captainsafia (recent owners of this code)
Summary
In SDK
11.0.100-preview.6.26313.102, building or publishing a .NET MAUI app that uses BlazorWebView and references a Razor Class Library fails on multiple TFMs (Windows AND Apple) with:The same project builds and publishes cleanly on SDK
11.0.100-preview.5.26256.105.Environment
11.0.100-preview.6.26313.10211.0.100-preview.5.26256.105net11.0-windows10.0.19041.0,net11.0-windows10.0.20348.0,net11.0-maccatalyst,net11.0-ios(any TFM where the BlazorWebView package targets are imported)Build Windows (Debug),Build Windows (Release),Build macOS (Release),Samples windows(integration test)Microsoft.NET.Sdk.RazorGenerateStaticWebAssetsPublishManifestGenerateStaticWebAssetEndpointsManifest.dotnet\sdk\11.0.100-preview.6.26313.102\Sdks\Microsoft.NET.Sdk.StaticWebAssets\targets\Microsoft.NET.Sdk.StaticWebAssets.Publish.targets(55,5)Repro shape
A MAUI Hybrid app csproj (
<Project Sdk="Microsoft.NET.Sdk.Razor">) that:wwwroot/folder with at least oneMaui.Controls.Sample.lib.module.jsplus acss/app.css.MauiRazorClassLibrarySample.csproj) that also haswwwroot/content and scoped CSS.Microsoft.AspNetCore.Components.WebView.Maui) — preview.6 SDK assemblies for that package include a_framework/blazor.modules.jsonstatic web asset.The full failing project is publicly available:
src/Controls/samples/Controls.Sample/Maui.Controls.Sample.csprojon the .NET MAUI net11.0 branch.Root cause (from inspecting the binlog)
Three distinct
StaticWebAssetEndpointitems collide on the sameRoute='_framework/blazor.modules.json':All).packages\microsoft.aspnetcore.components.webview\11.0.0-preview.6.26313.102\staticwebassets\blazor.modules.jsonartifacts\obj\Maui.Controls.Sample\Release\net11.0-windows10.0.20348.0\win-x64\jsmodules\jsmodules.build.manifest.jsonartifacts\obj\Maui.Controls.Sample\Release\net11.0-windows10.0.20348.0\win-x64\jsmodules\jsmodules.publish.manifest.jsonAsset #3 (note the
.publish.segment in the path) appears to be new in preview.6 — preview.5 only producedjsmodules.build.manifest.json.Looking at the failing code in
src/StaticWebAssetsSdk/Tasks/GenerateStaticWebAssetEndpointsManifest.cs:ChooseNearestAssetKind(group, "Publish")is returning >1 asset for the_framework/blazor.modules.jsongroup, andSingleOrDefault()rejects it. The same pattern repeats for several_content/MauiRazorClassLibrarySample/*routes where the raw asset, the.gzcompressed asset, and the.brpublish-compressed asset collide under the same target path.Likely culprit
The behavior change in preview.6 is consistent with #54353 — Add support for materializing framework static web assets at project-to-project reference boundaries (merged 2026-05-18). That PR changes how framework assets from package references flow across P2P boundaries, which is exactly the boundary being crossed in this scenario (Razor app → Razor class library → BlazorWebView package).
I haven't bisected to confirm — happy to do so if useful.
Reproduction
The simplest public repro is to run
dotnet buildon a checkout of the.NET MAUI net11.0branch with SDK11.0.100-preview.6.26313.102. TheBuild Windowsjobs of any maui-pr build on dotnet/maui PR #35364 (which bumps SDK from preview.5 → preview.6) fail with this exception; the corresponding stage on thenet11.0branch (still on preview.5) is green.Reference failing build: Azure DevOps 1463118, job
Build Windows (Release). Binlog is from that build; happy to attach (or grab from the AzDOWindows_NT_Build Windows (Release)_Attempt1artifact).Expected behavior
The Publish manifest generation should disambiguate
Build-kind,Publish-kind, andAll-kind assets that map to the same target route, producing exactly one chosen asset per route per manifest kind — not throwing.Workaround on consumer side?
Not aware of a clean opt-out. Removing the
MauiRazorClassLibrarySampleProjectReference avoids the failure but is not a real solution. Suggestions welcome.Related prior art
SingleOrDefaultexception in the siblingGenerateStaticWebAssetsDevelopmentManifestclass; root cause was also two assets collapsing to the same target path.[StaticWebAssets] Fix duplicate asset detection in GroupAssetsByTargetPath(Dec 2025).Handle duplicate static web asset identities gracefully(Mar 2026).cc @javiercn @captainsafia (recent owners of this code)