[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
Open
[release/10.0] Guard EF file generation during commandline builds to fix AOT build fork bomb#38403Copilot wants to merge 1 commit into
Copilot wants to merge 1 commit into
Conversation
Co-authored-by: AndriySvyryd <6539701+AndriySvyryd@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
AndriySvyryd
June 10, 2026 20:50
View session
There was a problem hiding this comment.
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=buildas a global property toMSBuildWorkspace.CreateinsideDbContextOperations.PrecompileQueries. - Add an explanatory comment documenting why the global property is required to prevent EF generation target re-entrancy.
artl93
approved these changes
Jun 11, 2026
artl93
left a comment
Member
There was a problem hiding this comment.
Approved - preventing additional regression on recent, unshipped fix.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_EFGenerationStageglobal property toMSBuildWorkspace.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 compilationPrecompileQueriesanalyzes (via_EFProcessGeneratedFiles, which has no stage guard).Customer impact
Users who enabler
EFOptimizeContext=truetogether 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
DesignTimeBuildguard introduced there did not cover the commandline path.Regression
Not a regression.
Testing
No automated tests modified. The
Microsoft.EntityFrameworkCore.Tasksintegration 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.