Skip to content

[release/10.0] Guard EF file generation during commandline builds to fix AOT build fork bomb#38403

Open
Copilot wants to merge 1 commit into
release/10.0from
copilot/investigate-issue-38087
Open

[release/10.0] Guard EF file generation during commandline builds to fix AOT build fork bomb#38403
Copilot wants to merge 1 commit into
release/10.0from
copilot/investigate-issue-38087

Conversation

Copilot AI commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Follow up to #38386

Description
PR #38386 guarded against Visual Studio design-time builds by checking DesignTimeBuild != 'True', but the guard was not effective for the commanline build code path. The fix is to pass the _EFGenerationStage global property to MSBuildWorkspace.Create. The EF generation targets check '$(_EFGenerationStage)'=='' before running, so supplying a non-empty value stops re-entrancy. The already-generated, up-to-date files are still included in the compilation PrecompileQueries analyzes (via _EFProcessGeneratedFiles, which has no stage guard).

Customer impact
Users who enabler EFOptimizeContext=true together with Native AOT will see commandline builds hang or crash (fork bomb). There is no practical workaround other than disabling precompiled queries.

How found
Follow-up discovered while investigating issue #38087 after merging #38386; the DesignTimeBuild guard introduced there did not cover the commandline path.

Regression
Not a regression.

Testing
No automated tests modified. The Microsoft.EntityFrameworkCore.Tasks integration has no out-of-process MSBuild test coverage. The fix was validated manually.

Risk
Low. One-line change that only affects this scenario; normal build and publish generation is completely unaffected.

Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot AI requested a review from AndriySvyryd June 10, 2026 20:50
@AndriySvyryd AndriySvyryd changed the title [release/10.0] Prevent ef.dll PrecompileQueries MSBuildWorkspace build re-entrancy fork bomb [release/10.0] Guard EF file generation during commandline builds to fix AOT build fork bomb Jun 10, 2026
@AndriySvyryd AndriySvyryd requested a review from Copilot June 10, 2026 21:01

Copilot AI left a comment

Copy link
Copy Markdown

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 prevents EF’s build-time code generation targets from being re-invoked during the Roslyn MSBuildWorkspace project load used by PrecompileQueries, avoiding re-entrant MSBuild execution that can cause a command-line AOT build “fork bomb”.

Changes:

  • Pass _EFGenerationStage=build as a global property to MSBuildWorkspace.Create inside DbContextOperations.PrecompileQueries.
  • Add an explanatory comment documenting why the global property is required to prevent EF generation target re-entrancy.

@AndriySvyryd AndriySvyryd marked this pull request as ready for review June 10, 2026 21:10
@AndriySvyryd AndriySvyryd requested a review from a team as a code owner June 10, 2026 21:10

@artl93 artl93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Approved - preventing additional regression on recent, unshipped fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants