Skip to content

Document SetTargetFramework bin/obj clash on single-targeting ProjectReferences#853

Open
ViktorHofer wants to merge 5 commits into
mainfrom
settargetframework-bin-obj-clash
Open

Document SetTargetFramework bin/obj clash on single-targeting ProjectReferences#853
ViktorHofer wants to merge 5 commits into
mainfrom
settargetframework-bin-obj-clash

Conversation

@ViktorHofer

Copy link
Copy Markdown
Member

Summary

Documents that SetTargetFramework metadata must not be set on a ProjectReference pointing to a non-multi-targeting (single-targeting) project.

Setting SetTargetFramework="TargetFramework=<tfm>" on such a reference injects TargetFramework as a global property on the referenced project. For a single-targeting project that property is path-neutral — the project already resolves to bin\<config>\<tfm>\ / obj\<config>\<tfm>\ on its own — so it does not change the output path; it only forks a distinct MSBuild project instance (project, {TargetFramework=<tfm>}). Meanwhile the solution/graph builds the same project as (project, {}). Both share the same OutputPath/IntermediateOutputPath, so the project is built twice to the same location — a bin/obj clash under parallel builds.

The P2P protocol itself correctly omits the TargetFramework global property for non-multi-targeting references; SetTargetFramework overrides that safe default and reintroduces the clash.

Motivated by dotnet/sdk#55109 (review).

Changes

  • msbuild-antipatterns: new AP-23 with BAD/GOOD examples, mechanism, detection, and when SetTargetFramework is legitimate (multi-targeting only); added to the quick-reference checklist; updated the SKILL.md pointer to "AP-16 through AP-23".
  • check-bin-obj-clash: new "Common Causes and Fixes" subsection cross-referencing AP-23, a note on the TargetFramework row in the global-properties table, and an extended USE FOR clause for discoverability.

…References

Setting SetTargetFramework metadata on a ProjectReference to a non-multi-targeting project injects a path-neutral TargetFramework global property, forking a redundant project instance that shares the same OutputPath/IntermediateOutputPath as the solution-rooted build. The project is built twice, causing a bin/obj clash under parallel builds.

Adds AP-23 to the msbuild-antipatterns catalog and a matching Common Causes and Fixes section plus global-properties note to the check-bin-obj-clash skill.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 2, 2026 05:51
@ViktorHofer ViktorHofer requested review from a team and JanKrivanek as code owners July 2, 2026 05:51
@ViktorHofer ViktorHofer requested a review from MichaelSimons July 2, 2026 05:51
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Skill Coverage Report

Plugin Skill Covered Coverage
⚠️ dotnet-msbuild check-bin-obj-clash 9/13 69.2%
Uncovered: dotnet-msbuild/check-bin-obj-clash
  • [WorkflowStep] Step 2: Get an overview and list projects (line 48)
  • [WorkflowStep] Step 5: Check for double writes (line 62)
  • [WorkflowStep] Step 2: Replay the Binary Log to Text (line 78)
  • [WorkflowStep] Step 3: List All Projects (line 84)

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 updates the dotnet-msbuild plugin documentation to explicitly warn against using SetTargetFramework metadata on ProjectReference items that point to single-targeting projects, because it can fork a redundant MSBuild project instance that writes to the same bin/ and obj/ paths and causes parallel-build clashes.

Changes:

  • Adds a new msbuild anti-pattern (AP-23) documenting why SetTargetFramework is harmful on ProjectReference to single-targeting projects, with BAD/GOOD examples and guidance on when it is appropriate (multi-targeting only).
  • Updates the msbuild-antipatterns SKILL pointer and quick-reference checklist to include AP-23.
  • Extends check-bin-obj-clash documentation with a new “Common Causes and Fixes” subsection for this scenario and clarifies the TargetFramework global-property table row with the single-targeting exception.
Show a summary per file
File Description
plugins/dotnet-msbuild/skills/msbuild-antipatterns/SKILL.md Updates the “additional anti-patterns” pointer to include AP-23.
plugins/dotnet-msbuild/skills/msbuild-antipatterns/references/additional-antipatterns.md Adds AP-23 documentation and includes it in the quick-reference checklist.
plugins/dotnet-msbuild/skills/check-bin-obj-clash/SKILL.md Documents SetTargetFramework→single-targeting ProjectReference as a common bin/obj clash cause; updates global-property notes for TargetFramework.

Copilot's findings

Tip

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

  • Files reviewed: 3/3 changed files
  • Comments generated: 0

@ViktorHofer

Copy link
Copy Markdown
Member Author

/evaluate

github-actions Bot added a commit that referenced this pull request Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Skill Validation Results

Skill Scenario Quality Skills Loaded Overfit Verdict
msbuild-antipatterns Review MSBuild files for anti-patterns and style issues 4.7/5 → 4.7/5 ✅ msbuild-antipatterns; tools: skill, glob, edit / ⚠️ NOT ACTIVATED ✅ 0.09
msbuild-antipatterns Add a module to an F# project 5.0/5 → 5.0/5 ⚠️ NOT ACTIVATED ✅ 0.09 [1]
msbuild-antipatterns Fix broken file order causing FS0039 4.0/5 → 4.0/5 ⚠️ NOT ACTIVATED ✅ 0.09 [2]
msbuild-antipatterns Add a signature file to define public API 5.0/5 → 5.0/5 ⚠️ NOT ACTIVATED ✅ 0.09 [3]
check-bin-obj-clash Diagnose bin/obj output path clashes 3.7/5 → 5.0/5 🟢 ✅ check-bin-obj-clash; tools: skill, binlog-binlog_evaluations, binlog-binlog_double_writes, binlog-binlog_properties, binlog-binlog_evaluation_global_properties, binlog-binlog_evaluation_properties, edit / ✅ check-bin-obj-clash; tools: skill, binlog-binlog_double_writes, binlog-binlog_evaluations, binlog-binlog_properties, binlog-binlog_evaluation_global_properties, binlog-binlog_evaluation_properties, glob ✅ 0.16 [4]

[1] ⚠️ High run-to-run variance (CV=110%) — consider re-running with --runs 5. (Plugin) Quality unchanged but weighted score is -1.9% due to: tokens (116601 → 171087)
[2] (Plugin) Quality unchanged but weighted score is -3.2% due to: tokens (72444 → 119822)
[3] (Plugin) Quality unchanged but weighted score is -3.8% due to: tokens (76388 → 135858)
[4] ⚠️ High run-to-run variance (CV=66%) — consider re-running with --runs 5

Model: claude-opus-4.6 | Judge: claude-opus-4.6

🔍 Full Results - additional metrics and failure investigation steps

To investigate failures, paste this to your AI coding agent:

For PR 853 in dotnet/skills, download eval artifacts with gh run download 28568835499 --repo dotnet/skills --pattern "skill-validator-results-*" --dir ./eval-results, then fetch https://raw.githubusercontent.com/dotnet/skills/862fd74a28597d942fa912300f5c3ad32d21c4f8/eng/skill-validator/src/docs/InvestigatingResults.md and follow it to analyze the results.json files. Diagnose each failure, suggest fixes to the eval.yaml and skill content, and tell me what to fix first.

▶ Sessions Visualisation -- interactive replay of all evaluation sessions
📊 Session Analytics (preview) -- aggregated metrics across evaluation sessions

Viktor Hofer and others added 2 commits July 2, 2026 08:19
Refine AP-23 and the check-bin-obj-clash guidance to reflect two additional cases: (1) the clash only occurs when the injected TFM equals the single-targeting project's own TFM (path-neutral); injecting a DIFFERENT TFM changes the output path and is a valid override, and (2) for framework-incompatible references (e.g. .NETFramework test project -> single-targeting .NETCoreApp), SkipGetTargetFrameworkProperties=true and ReferenceOutputAssembly=false are also required.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
SkipGetTargetFrameworkProperties=true and ReferenceOutputAssembly=false are required whenever the referencing and referenced projects target incompatible frameworks, independent of single- vs multi-targeting and independent of SetTargetFramework. Decouple that rule from the SetTargetFramework override case in both AP-23 and the check-bin-obj-clash skill.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings July 2, 2026 06:22

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.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new

@ViktorHofer ViktorHofer marked this pull request as draft July 2, 2026 06:45
When SkipGetTargetFrameworkProperties=true bypasses P2P negotiation, the referencing project's TargetFramework global property can flow into a single-targeting referenced project and build it under the wrong TFM/output path. Guard with either SetTargetFramework (pin) or UndefineProperties=TargetFramework (strip), not both.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ViktorHofer ViktorHofer marked this pull request as ready for review July 2, 2026 07:07
Copilot AI review requested due to automatic review settings July 2, 2026 07:07

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.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 0 new

check-bin-obj-clash: extend ClashTest with a single-targeting ToolLib and a ConsumerApp that references it with redundant same-TFM SetTargetFramework, forking a second ToolLib instance that builds to the same bin/obj (verified: ToolLib builds twice). Adds rubric items for identifying and fixing it.

msbuild-antipatterns: LibB now references LibA with redundant same-TFM SetTargetFramework; adds a rubric item for detecting AP-23 in the static review scenario. Both eval.yaml and eval.vally.yaml updated.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot added the pr-state/ready-for-eval PR is mergeable and awaiting evaluation label Jul 2, 2026
github-actions Bot added a commit that referenced this pull request Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Skill Validation Results

Skill Scenario Quality Skills Loaded Overfit Verdict
msbuild-antipatterns Review MSBuild files for anti-patterns and style issues 5.0/5 → 4.7/5 🔴 ✅ msbuild-antipatterns; tools: skill, edit / ⚠️ NOT ACTIVATED ✅ 0.09
msbuild-antipatterns Add a module to an F# project 4.3/5 → 5.0/5 🟢 ⚠️ NOT ACTIVATED ✅ 0.09 [1]
msbuild-antipatterns Fix broken file order causing FS0039 4.0/5 → 4.0/5 ⚠️ NOT ACTIVATED ✅ 0.09 [2]
msbuild-antipatterns Add a signature file to define public API 5.0/5 → 5.0/5 ⚠️ NOT ACTIVATED ✅ 0.09 [3]
check-bin-obj-clash Diagnose bin/obj output path clashes 4.0/5 → 4.7/5 🟢 ✅ check-bin-obj-clash; tools: skill, binlog-binlog_evaluations, binlog-binlog_double_writes, binlog-binlog_evaluation_global_properties, binlog-binlog_properties, binlog-binlog_evaluation_properties, edit, binlog-binlog_diagnose, binlog-binlog_overview, glob / ✅ check-bin-obj-clash; tools: binlog-binlog_double_writes, skill, binlog-binlog_evaluations, binlog-binlog_properties, binlog-binlog_evaluation_global_properties, binlog-binlog_evaluation_properties, glob, binlog-binlog_diagnose, edit 🟡 0.23 [4]

[1] ⚠️ High run-to-run variance (CV=140%) — consider re-running with --runs 5
[2] (Plugin) Quality unchanged but weighted score is -4.0% due to: tokens (72541 → 128244)
[3] ⚠️ High run-to-run variance (CV=52%) — consider re-running with --runs 5. (Plugin) Quality unchanged but weighted score is -3.5% due to: tokens (75398 → 127194)
[4] ⚠️ High run-to-run variance (CV=521%) — consider re-running with --runs 5

Model: claude-opus-4.6 | Judge: claude-opus-4.6

🔍 Full Results - additional metrics and failure investigation steps

To investigate failures, paste this to your AI coding agent:

For PR 853 in dotnet/skills, download eval artifacts with gh run download 28573193930 --repo dotnet/skills --pattern "skill-validator-results-*" --dir ./eval-results, then fetch https://raw.githubusercontent.com/dotnet/skills/c40b2a6f94a266c92a504de700205a3640fed0f1/eng/skill-validator/src/docs/InvestigatingResults.md and follow it to analyze the results.json files. Diagnose each failure, suggest fixes to the eval.yaml and skill content, and tell me what to fix first.

▶ Sessions Visualisation -- interactive replay of all evaluation sessions
📊 Session Analytics (preview) -- aggregated metrics across evaluation sessions

@github-actions github-actions Bot added waiting-on-review PR state label and removed pr-state/ready-for-eval PR is mergeable and awaiting evaluation labels Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

✅ Evaluation passed for c40b2a6. cc @ViktorHofer @JanKrivanek @dotnet/skills-msbuild-reviewers — please review.

@ViktorHofer

Copy link
Copy Markdown
Member Author

/evaluate

github-actions Bot added a commit that referenced this pull request Jul 2, 2026
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Skill Validation Results

Skill Scenario Quality Skills Loaded Overfit Verdict
msbuild-antipatterns Review MSBuild files for anti-patterns and style issues 5.0/5 → 4.7/5 🔴 ✅ msbuild-antipatterns; tools: skill, edit / ⚠️ NOT ACTIVATED ✅ 0.07
msbuild-antipatterns Add a module to an F# project 5.0/5 → 5.0/5 ⚠️ NOT ACTIVATED ✅ 0.07 [1]
msbuild-antipatterns Fix broken file order causing FS0039 4.0/5 → 4.0/5 ⚠️ NOT ACTIVATED ✅ 0.07 [2]
msbuild-antipatterns Add a signature file to define public API 5.0/5 → 5.0/5 ⚠️ NOT ACTIVATED ✅ 0.07 [3]
check-bin-obj-clash Diagnose bin/obj output path clashes 3.7/5 → 4.3/5 🟢 ✅ check-bin-obj-clash; tools: skill, binlog-binlog_overview, binlog-binlog_double_writes, binlog-binlog_evaluations, binlog-binlog_properties, binlog-binlog_evaluation_global_properties, glob, binlog-binlog_evaluation_properties, edit / ✅ check-bin-obj-clash; tools: binlog-binlog_double_writes, skill, binlog-binlog_evaluations, binlog-binlog_properties, binlog-binlog_evaluation_global_properties, binlog-binlog_evaluation_properties, glob, edit ✅ 0.18 [4]

[1] (Plugin) Quality unchanged but weighted score is -3.7% due to: tokens (97914 → 171199)
[2] (Isolated) Quality unchanged but weighted score is -2.5% due to: tokens (77755 → 115727)
[3] (Plugin) Quality unchanged but weighted score is -4.0% due to: tokens (75474 → 135090)
[4] ⚠️ High run-to-run variance (CV=299%) — consider re-running with --runs 5

Model: claude-opus-4.6 | Judge: claude-opus-4.6

🔍 Full Results - additional metrics and failure investigation steps

To investigate failures, paste this to your AI coding agent:

For PR 853 in dotnet/skills, download eval artifacts with gh run download 28580774901 --repo dotnet/skills --pattern "skill-validator-results-*" --dir ./eval-results, then fetch https://raw.githubusercontent.com/dotnet/skills/c40b2a6f94a266c92a504de700205a3640fed0f1/eng/skill-validator/src/docs/InvestigatingResults.md and follow it to analyze the results.json files. Diagnose each failure, suggest fixes to the eval.yaml and skill content, and tell me what to fix first.

▶ Sessions Visualisation -- interactive replay of all evaluation sessions
📊 Session Analytics (preview) -- aggregated metrics across evaluation sessions

@github-actions

github-actions Bot commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

✅ Evaluation passed for c40b2a6. cc @ViktorHofer @JanKrivanek @dotnet/skills-msbuild-reviewers — please review.

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

Labels

waiting-on-review PR state label

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants