.NET 11 regression: malformed linker XML in Components.Endpoints causes IL2101 during trimmed publishing

Open Beginner friendly
#70,236 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
csharp
Domain
build-system

Research direction

Start with the embedded ILLink.Substitutions.xml resource in the Microsoft.AspNetCore.Components.Endpoints project, and check its assembly fullname against the one the Forms assembly actually uses. The issue points to commit 309d909185 (PR #65903) as the source of the bad entry. Run the console repro from the issue with -p:PublishTrimmed=true -p:ILLinkTreatWarningsAsErrors=true; done means IL2101 no longer appears and publishing succeeds.

Written by the indexing model from the issue text.

Description

area-blazor NativeAOT Regression
Describe the bug

Microsoft.AspNetCore.Components.Endpoints embeds an ILLink.Substitutions.xml resource whose assembly fullname incorrectly targets Microsoft.AspNetCore.Components.Forms. This causes IL2101 during trimmed publishing.

This affects trimmed publishing of Blazor applications and can also occur in non-Blazor applications. A console application referencing Microsoft.AspNetCore.App and using IHtmlHelper reproduces the problem without RazorSlices, Razor files, MVC services, or Blazor registration.

When IL2101 is treated as an error, publishing fails with NETSDK1144.

Expected Behavior

The embedded linker XML targets the correct assembly, and the application publishes without IL2101, as it does with .NET 10.

Steps To Reproduce

Using .NET SDK 11.0.100-rc.3.26522.148, create a console application with these files.

Repro.csproj

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net11.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
</Project>

Program.cs

System.Console.WriteLine(
    typeof(Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper).FullName);

Publish with trimming enabled:

dotnet publish -c Release -r win-x64 --self-contained true -p:PublishAot=false -p:PublishTrimmed=true -p:ILLinkTreatWarningsAsErrors=false

Observe IL2101 for the embedded ILLink.Substitutions.xml resource in Microsoft.AspNetCore.Components.Endpoints.

Repeat with -p:ILLinkTreatWarningsAsErrors=true to observe publishing fail with NETSDK1144.

Exceptions (if any)

IL2101 reports malformed linker XML. Treating the warning as an error causes NETSDK1144.

.NET Version

Reported with SDK 11.0.100-rc.3.26522.148.

The equivalent net10.0 reproduction using SDK 10.0.403 and runtime/linker packs 10.0.14 does not emit IL2101.

Anything else?

According to Damian's investigation:

  • ViewFeatures leads the linker to Components.Endpoints. Its XML is parsed even though Endpoints is unmarked and removed from the final output.
  • The malformed resource was introduced by commit 309d909185 in #65903 and remained incorrect on the inspected main snapshot.
  • The .NET 10 linker already performs the cross-assembly XML check, so this is a framework resource regression rather than a new linker diagnostic.

This issue isolates the IL2101 problem described in #69270 and tracks its impact on both Blazor and non-Blazor applications.

Proposed servicing target: the first .NET 11 servicing window in December, subject to servicing approval.

Dominant language
C#
Stars
38.5k
Forks
13k
Avg merge
1d 17h
Merged PRs (30d)
164

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/aspnetcore

All issues in dotnet/aspnetcore

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.