Skip to content

Revert "Aggregate ASP.NET Core tool executables (#7020)" - #7124

Merged
lewing merged 1 commit into
mainfrom
revert-aspnetcore-aggregate-tools
Jun 8, 2026
Merged

lewing merged 1 commit into
mainfrom
revert-aspnetcore-aggregate-tools

Conversation

@lewing

@lewing lewing commented Jun 8, 2026 •

Copy link
Copy Markdown
Member

This reverts commit 7150f20 (PR #7020).

Problem

The aspnetcoretools aggregation introduced by #7020 is causing ILC SourceLinkWriter crashes on Windows, breaking all main branch Windows vertical builds (both official and PR CI).

Error: ILCompiler.SourceLinkWriter..ctor at SourceLinkWriter.cs:27 (File.CreateText) throws a file-locked exception:

aspnetcoretools.sourcelink because it is being used by another process

Impact:

Root Cause Analysis

The crash has three contributing factors:

1. Multi-RID parallel ILC writes to same file

aspnetcoretools.csproj sets RuntimeIdentifiers (potentially multiple RIDs) + NativeLib=Shared. MSBuild creates parallel build iterations per RID, and all ILC processes race on writing aspnetcoretools.sourcelink via File.CreateText() — which on Windows uses exclusive file locking.

2. Test project triggers overlapping publishes

Microsoft.AspNetCore.Tools.NativeAot.Tests.csproj has a PublishNativeAotToolsForTests target that runs BeforeTargets="Build" and calls MSBuild Targets="Publish" on aspnetcoretools.csproj. This can overlap with the main build's publish of aspnetcoretools, creating concurrent ILC processes writing to the same intermediate files.

3. Individual tools still have PublishAot=true

The three tool .csproj files (dotnet-dev-certs, dotnet-user-jwts, dotnet-user-secrets) still declare PublishAot=true independently. This causes double ILC compilation — once via the aggregate project and once individually — creating additional file contention.

Why Windows-only?

Linux/macOS don't enforce exclusive file locking on File.CreateText, so concurrent writes succeed silently. Windows does enforce it, causing IOException at SourceLinkWriter.cs:27.

Timeline

Suggestions for re-landing

To re-land the aggregation fix, consider:

  • Remove PublishAot=true from the individual tool projects since they're now aggregated
  • Guard the test project's PublishNativeAotToolsForTests target to avoid overlapping with the main build
  • Add BuildInParallel="false" or otherwise serialize the ILC sourcelink writes

cc @DamianEdwards @dotnet/aspnet-build

Copilot AI review requested due to automatic review settings June 8, 2026 15:45
@dotnet-policy-service
dotnet-policy-service Bot requested review from a team June 8, 2026 15:46
@DamianEdwards

Copy link
Copy Markdown
Member

@MichalStrehovsky

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR reverts the ASP.NET Core aggregated tool packaging introduced in #7020 (commit 7150f202...) to unblock Windows vertical builds that are failing due to an ILCompiler.SourceLinkWriter sharing-violation crash during NativeAOT compilation.

Changes:

  • Removes the aspnetcoretools NativeAOT aggregate tool project and reverts CLI/tool layout logic back to resolving dotnet-dev-certs, dotnet-user-jwts, and dotnet-user-secrets as individual bundled tools.
  • Updates ASP.NET Core NativeAOT tool tests to publish/run each tool independently (instead of publishing the aggregate project).
  • Cleans up related solution/build inputs by removing the aggregate project from sln filters / solution definitions.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/sdk/test/dotnet.Tests/CommandFactoryTests/GivenADotnetToolsCommandResolver.cs Removes unit coverage specific to aggregate tool package resolution.
src/sdk/src/Layout/redist/targets/GenerateBundledVersions.targets Adjusts bundled CLI tools props generation for tool obsoletion references.
src/sdk/src/Layout/redist/targets/BundledDotnetTools.targets Reverts bundled tool list to include individual ASP.NET Core tools instead of the aggregate package.
src/sdk/src/Cli/dotnet/CommandFactory/CommandResolution/DotnetToolsCommandResolver.cs Removes aggregate-package fallback resolution logic from the CLI tool resolver.
src/aspnetcore/src/Tools/Tools.slnf Removes the aggregate NativeAOT project from the Tools solution filter.
src/aspnetcore/src/Tools/Shared/TestHelpers/NativeAotToolRunner.cs Updates test runner to locate published tools under per-tool subdirectories.
src/aspnetcore/src/Tools/NativeAot/test/Microsoft.AspNetCore.Tools.NativeAot.Tests.csproj Publishes each NativeAOT tool under test individually into per-tool publish directories.
src/aspnetcore/src/Tools/NativeAot/aspnetcoretools/aspnetcoretools.csproj Deletes the aggregate tool project.
src/aspnetcore/src/Tools/NativeAot/AspNetCoreTools.NativeAot.props Removes aggregate-tool-specific NativeAOT defaults (moved to common targets).
src/aspnetcore/src/Tools/dotnet-user-secrets/src/dotnet-user-secrets.csproj Removes aggregate-tool NativeAOT props import and simplifies RID settings for tool publishing.
src/aspnetcore/src/Tools/dotnet-user-jwts/src/dotnet-user-jwts.csproj Removes aggregate-tool NativeAOT props import and simplifies RID settings for tool publishing.
src/aspnetcore/src/Tools/dotnet-dev-certs/src/dotnet-dev-certs.csproj Removes aggregate-tool NativeAOT props import and simplifies RID settings for tool publishing.
src/aspnetcore/src/Tools/Directory.Build.targets Centralizes NativeAOT publish property defaults previously in the removed props file.
src/aspnetcore/eng/Build.props Removes the aggregate project from repo build inclusion/exclusion lists.
src/aspnetcore/AspNetCore.slnx Removes the aggregate NativeAOT project from the solution.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

This reverts commit 7150f20.

The aspnetcoretools aggregation is causing ILC SourceLinkWriter crashes
on Windows due to a file locking race in File.CreateText at
ILCompiler.SourceLinkWriter..ctor (SourceLinkWriter.cs:27). The
aspnetcoretools.sourcelink file is being accessed by multiple processes
simultaneously, causing all main branch Windows vertical builds to fail.

Co-authored-by: Copilot <[email protected]>
@lewing
lewing force-pushed the revert-aspnetcore-aggregate-tools branch from 93f83a4 to ad98418 Compare June 8, 2026 15:55
@lewing
lewing enabled auto-merge June 8, 2026 16:10
@lewing
lewing merged commit 290a083 into main Jun 8, 2026
11 checks passed
@lewing
lewing deleted the revert-aspnetcore-aggregate-tools branch June 8, 2026 18:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants