Repository navigation
Fix skipped target hooks in out-of-process builds - #15482
JanProvaznik merged 2 commits into
Conversation
Preserve case-insensitive target hook lookups when transferring an entire ProjectInstance to an out-of-process worker. Otherwise a differently cased target name can execute its body while silently skipping its before and after hooks. Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
🟡 Changes recommended
The deserialization comparer can merge distinct valid target names on .NET Framework x86/x64, overwriting hook lists and causing hooks to be skipped or associated with the wrong target.
1 open issue
What changed in this PR
This PR addresses skipped BeforeTargets and AfterTargets hooks when MSBuild transfers a complete project instance to an out-of-process worker and the requested target casing differs.
Changes:
- Adds case-insensitive comparers when deserializing target-hook dictionaries.
- Adds regression coverage for alternate and canonical target casing, plus an in-process control, verifying both hooks execute exactly once.
| File | Description |
|---|---|
src/Build/Instance/ProjectInstance.cs |
Adds comparers to deserialized before/after target-hook dictionaries. |
src/Build.UnitTests/BackEnd/BuildManager_Tests.cs |
Tests hook execution across target casing and process modes. |
Review effort: Balanced
There was a problem hiding this comment.
MSBuild Target Authoring Conventions — LGTM
Warning
Firewall blocked 3 domains
The following domains were blocked by the firewall during workflow execution:
api.github.comgithub.compatchdiff.githubusercontent.com
[!TIP]
api.github.com is blocked because GitHub API access uses the built-in GitHub tools by default. Instead of adding api.github.com to network.allowed, use tools.github.mode: gh-proxy for direct pre-authenticated GitHub CLI access without requiring network access to api.github.com:
tools:
github:
mode: gh-proxySee GitHub Tools for more information on gh-proxy mode.
To allow these domains, add them to the network.allowed list in your workflow frontmatter:
network:
allowed:
- defaults
- "api.github.com"
- "github.com"
- "patchdiff.githubusercontent.com"See Network Configuration for more information.
Generated by Expert Code Review (on open) for #15482 · copilot · gpt56 · 635.4 AIC · ⌖ 0.522 AIC · ⊞ 20.9K
Co-authored-by: Copilot Autofix powered by AI <[email protected]>

When a complete project instance is transferred to an out-of-process worker, requesting
buildcan executeBuildwhile silently skipping itsBeforeTargetsandAfterTargetshooks. The transferred hook dictionaries lose their case-insensitive comparer. Preserve MSBuild's target-name comparison semantics across the transfer so hooks run regardless of the requested target casing, including builds initiated by Visual Studio.The regression covers alternate target casing, canonical casing, and an in-process control, and checks that both hooks execute exactly once.