Skip to content

Fully dedupe aspnetcoretools build to fix NativeAOT sourcelink race - #67327

Merged
wtgodbe merged 1 commit into
dotnet:mainfrom
wtgodbe:wtgodbe/fix-nativeaot-sourcelink-dedupe
Jun 20, 2026
Merged

wtgodbe merged 1 commit into
dotnet:mainfrom
wtgodbe:wtgodbe/fix-nativeaot-sourcelink-dedupe

Conversation

@wtgodbe

@wtgodbe wtgodbe commented Jun 19, 2026

Copy link
Copy Markdown
Member

Summary

Fixes the intermittent NativeAOT build failure where ilc errors with:

The process cannot access the file '...\artifacts\obj\aspnetcoretools\Release\net11.0\win-x64\native\aspnetcoretools.sourcelink' because it is being used by another process.

Why #67320 wasn't sufficient

#67320 changed the NativeAot.Tests → aspnetcoretools ProjectReference to pass Properties="TargetFramework=$(DefaultNetCoreTargetFramework)", intending to dedupe onto the solution traversal's build. But aspnetcoretools.csproj is single-targeted, so the solution traversal builds it with no TargetFramework global property.

MSBuild keys a project instance by (path + global-properties set). Passing TargetFramework=net11.0 therefore produces a different key from the traversal's {… no TargetFramework} build, so the two are not deduped — they run two concurrent NativeAOT compiles that race on the shared intermediate aspnetcoretools.sourcelink file.

Binlog from build 1473385 (Tests: Helix x64 Subset 2) confirms two concurrent Build instances of aspnetcoretools.csproj, identical in every global property except TargetFramework (one <none>, one net11.0), with the IOException landing in the TargetFramework=net11.0 instance.

Fix

Drop the explicit property and UndefineProperties="TargetFramework;RuntimeIdentifier" so the reference resolves to the same project instance the traversal builds and dedupes onto it (the reference already sets SkipGetTargetFrameworkProperties="true"). Sequencing intent is preserved via the unchanged ReferenceOutputAssembly="false" / Private="false" build-order edge.

PR dotnet#67320 attempted to fix the intermittent ILC sourcelink file lock
(aspnetcoretools.sourcelink 'being used by another process') by changing
the NativeAot.Tests ProjectReference to pass
Properties="TargetFramework=$(DefaultNetCoreTargetFramework)". That was
insufficient: the solution traversal builds the single-targeted
aspnetcoretools.csproj with NO TargetFramework global property, so passing
TargetFramework=net11.0 still produces a differently-keyed MSBuild project
instance. The two instances both run a NativeAOT compile concurrently and
race on the shared intermediate sourcelink file.

Drop the explicit property and UndefineProperties TargetFramework and
RuntimeIdentifier so this reference resolves to the same project instance
the traversal builds and dedupes onto it.

Co-authored-by: Copilot <[email protected]>
Copilot AI review requested due to automatic review settings June 19, 2026 23:33

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 fixes an intermittent NativeAOT build failure caused by concurrent builds of aspnetcoretools.csproj producing a shared intermediate *.sourcelink file, by ensuring MSBuild can dedupe the ProjectReference build onto the solution traversal’s already-running project instance.

Changes:

  • Stop forcing a separately-keyed aspnetcoretools project instance by removing the Properties="TargetFramework=..." override.
  • Add UndefineProperties="TargetFramework;RuntimeIdentifier" on the ProjectReference so the reference build resolves to the same global-properties set as the traversal build.
  • Update the inline comment to explain why the dedupe was not happening and how this fixes the race.

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.

2 participants