Fix Hash input in _GenerateVersionSourceFileCache target#8102
Conversation
The _TemplateProperties symbol is a property but was referenced with item-group syntax @(_TemplateProperties), which evaluates to empty. Changed to property syntax so the Hash task receives the actual version string, making the cache file reflect version changes and fixing incremental build invalidation for all projects with GenerateBuildInfo=true. Fixes #8034
There was a problem hiding this comment.
Pull request overview
Fixes the incremental-build cache for GenerateVersionSourceFile by correcting MSBuild syntax in Directory.Build.targets so the hash input reflects the actual Version=... property value (instead of hashing an empty value).
Changes:
- Update the
Hashtask invocation to pass_TemplatePropertiesusing property syntax ($()) rather than item syntax (@()), ensuring version changes invalidate the cache file and regenerateBuildInfo.csas intended.
Show a summary per file
| File | Description |
|---|---|
| Directory.Build.targets | Fixes _GenerateVersionSourceFileCache hashing input so incremental builds detect version changes and regenerate BuildInfo.cs. |
Copilot's findings
- Files reviewed: 1/1 changed files
- Comments generated: 0
Evangelink
left a comment
There was a problem hiding this comment.
Summary
Workflow: PR Nitpick Reviewer 🔍
Date: 2026-05-11
Repository: microsoft/testfx
Assessment
This is a minimal, precise bug fix with a single line changed. The fix correctly changes @(_TemplateProperties) (item-group syntax) to $(_TemplateProperties) (property syntax) so the Hash task receives the actual version string rather than an empty item collection.
No nitpicks found. The change is clean, correct, and the PR description thoroughly explains both the root cause and impact.
Positive Highlights ✅
- Surgical, focused fix — no unrelated changes
- Excellent PR description covering problem, fix, and impact
- The root cause analysis is spot-on: the item group
@(_TemplateProperties)was always empty because_TemplatePropertiesis a property, not an item group
🔍 Meticulously inspected by PR Nitpick Reviewer
🔍 Meticulously inspected by PR Nitpick Reviewer 🔍
Evangelink
left a comment
There was a problem hiding this comment.
Summary
Workflow: Expert Code Reviewer
Date: 2026-05-11
Repository: microsoft/testfx
Key Findings
No issues found. The fix is correct and minimal.
Root cause confirmed: _TemplateProperties is declared as a <PropertyGroup> property (line 29 of Directory.Build.targets). MSBuild item-group syntax @(_TemplateProperties) evaluates to empty when no item group of that name exists, so the Hash task received no input and always produced a constant hash — effectively disabling the incremental build check for BuildInfo.cs.
Fix is correct: Changing to $(_TemplateProperties) passes the property value ("Version=X.Y.Z") to the Hash task. MSBuild coerces the string into a single ITaskItem, which is well-defined behavior and matches the intended pattern used by dotnet/arcade.
Impact: All projects with GenerateBuildInfo=true will now correctly regenerate BuildInfo.cs on incremental builds when the version changes.
Recommendations
None — this is a precise, minimal, correct fix.
Generated by Expert Code Reviewer
🧠 Reviewed by Expert Code Reviewer 🧠
Summary
Fix incorrect MSBuild syntax in the
_GenerateVersionSourceFileCachetarget inDirectory.Build.targets.Problem
_TemplatePropertiesis defined as a property (<PropertyGroup>), but theHashtask referenced it with item-group syntax@(_TemplateProperties). Since no item group with that name exists,@(_TemplateProperties)always evaluates to empty — producing a constant hash regardless of the actual version value.This means the cache file never reflects version changes, so the
GenerateVersionSourceFiletarget's incremental build check (Inputs/Outputs) never detects that the version changed, andBuildInfo.csdoesn't get regenerated on incremental builds.Fix
Changed
@(_TemplateProperties)→$(_TemplateProperties)so theHashtask receives the actualVersion=X.Y.Zstring.Impact
Affects all projects with
GenerateBuildInfo=true:Fixes #8034