Skip to content

Fix Hash input in _GenerateVersionSourceFileCache target#8102

Merged
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/fix-version-cache-hash
May 11, 2026
Merged

Fix Hash input in _GenerateVersionSourceFileCache target#8102
Evangelink merged 1 commit into
mainfrom
dev/amauryleve/fix-version-cache-hash

Conversation

@Evangelink
Copy link
Copy Markdown
Member

Summary

Fix incorrect MSBuild syntax in the _GenerateVersionSourceFileCache target in Directory.Build.targets.

Problem

_TemplateProperties is defined as a property (<PropertyGroup>), but the Hash task 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 GenerateVersionSourceFile target's incremental build check (Inputs/Outputs) never detects that the version changed, and BuildInfo.cs doesn't get regenerated on incremental builds.

Fix

Changed @(_TemplateProperties)$(_TemplateProperties) so the Hash task receives the actual Version=X.Y.Z string.

Impact

Affects all projects with GenerateBuildInfo=true:

  • Microsoft.Testing.Extensions.CrashDump
  • Microsoft.Testing.Extensions.HangDump
  • Microsoft.Testing.Extensions.TrxReport
  • Microsoft.Testing.Extensions.Retry
  • Microsoft.Testing.Extensions.MSBuild
  • Microsoft.Testing.Extensions.VSTestBridge
  • Microsoft.Testing.Extensions.OpenTelemetry
  • MSTest.TestAdapter
  • MSTest.Engine
  • Microsoft.Testing.TestInfrastructure

Fixes #8034

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
Copilot AI review requested due to automatic review settings May 11, 2026 12:29
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 Hash task invocation to pass _TemplateProperties using property syntax ($()) rather than item syntax (@()), ensuring version changes invalidate the cache file and regenerate BuildInfo.cs as 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

Copy link
Copy Markdown
Member Author

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

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 _TemplateProperties is a property, not an item group

🔍 Meticulously inspected by PR Nitpick Reviewer

🔍 Meticulously inspected by PR Nitpick Reviewer 🔍

Copy link
Copy Markdown
Member Author

@Evangelink Evangelink left a comment

Choose a reason for hiding this comment

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

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 🧠

@Evangelink Evangelink merged commit a4716c7 into main May 11, 2026
40 of 43 checks passed
@Evangelink Evangelink deleted the dev/amauryleve/fix-version-cache-hash branch May 11, 2026 13:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[aw] Daily QA failed

2 participants