Skip to content

Invalidate generated source cache on MSBuild task updates - #10082

Merged
Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/fix-stale-generated-files
Jul 20, 2026
Merged

Amaury Levé (Evangelink) merged 2 commits into
mainfrom
dev/amauryleve/fix-stale-generated-files

Conversation

@Evangelink

Copy link
Copy Markdown
Member

Fixes #10056.

Summary

  • include the Microsoft.Testing.Platform.MSBuild.dll content hash in entry-point and self-registered-extension cache keys
  • avoid hashing when neither source-generation feature is enabled
  • add acceptance coverage that replaces the task assembly in place, verifies both sources regenerate, and verifies the next unchanged build remains incremental

Validation

  • repository build and package validation
  • GeneratedSourcesAreRegeneratedWhenMSBuildTaskChanges
  • existing C# entry-point cache matrix (12 cases; one parallel collision passed in isolation)
  • three independent review rounds, including MSBuild-specific review

Include the MSBuild task assembly content hash in both generated-source cache keys so package updates regenerate stale entry point and extension files.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 16fa9e8a-ead7-4ccd-b30e-12b4c96dfd43
Copilot AI review requested due to automatic review settings July 20, 2026 12:24
@Evangelink
Amaury Levé (Evangelink) enabled auto-merge (squash) July 20, 2026 12:26
@Evangelink Amaury Levé (Evangelink) added the state/needs-review Awaiting review from the team. label Jul 20, 2026

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

Fixes stale generated sources after MSBuild task updates by incorporating the task assembly hash into generation caches.

Changes:

  • Hashes the MSBuild task assembly for both source-generation caches.
  • Adds acceptance coverage for regeneration and subsequent incremental builds.
  • Avoids hashing when generation is disabled.
Show a summary per file
File Description
Microsoft.Testing.Platform.MSBuild.targets Adds task assembly hash to cache inputs.
MSBuildTests.GenerateEntryPoint.cs Tests regeneration after an in-place task update.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Medium

@github-actions

This comment has been minimized.

Evaluate source-generation flags before guarding file hashing, and keep each generator's calculation path independent. Cover self-registration-only task updates.

Co-authored-by: Copilot App <[email protected]>

Copilot-Session: 16fa9e8a-ead7-4ccd-b30e-12b4c96dfd43
Copilot AI review requested due to automatic review settings July 20, 2026 13:48

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.

Review details

  • Files reviewed: 2/2 changed files
  • Comments generated: 0 new
  • Review effort level: Medium

@github-actions

Copy link
Copy Markdown
Contributor

🧪 Test quality grade — PR #10082

GradeTestNotes
A (90–100) mod MSBuildTests_
EntryPoint.
GeneratedSourcesAreRegeneratedWhen
MSBuildTaskChanges
Clear AAA structure across all build phases; assertions verify exact task execution counts in binlogs — no issues found.

This advisory comment was generated automatically. Grades are heuristic
and informational — they do not block merging. Re-run with
/grade-tests.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • awmgmcpg

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "awmgmcpg"

See Network Configuration for more information.

🤖 Automated content by GitHub Copilot. Generated by the Grade Tests on PR (on open / sync) workflow. · 41.6 AIC · ⌖ 4.82 AIC · ⊞ 8.9K · [◷]( · ◷)

@PetSerAl

PetSerAl commented Jul 20, 2026 •

Copy link
Copy Markdown

IMHO could be solved with just

<_GenerateTestingPlatformEntryPointInputsCacheToHash Include="$(MicrosoftTestingPlatformMSBuildTaskFolder)" />

and

<_GenerateSelfRegisteredExtensionsInputsCacheToHash Include="$(MicrosoftTestingPlatformMSBuildTaskFolder)" />

no need for hashing. Restore put different versions in different version-spamped directories.
Assembly change in-place will not be covered, but it not the thing that should usually happens.

@Evangelink
Amaury Levé (Evangelink) merged commit 06b7711 into main Jul 20, 2026
49 of 52 checks passed
@Evangelink
Amaury Levé (Evangelink) deleted the dev/amauryleve/fix-stale-generated-files branch July 20, 2026 19:55
@Evangelink

Copy link
Copy Markdown
Member Author

Thanks for the suggestion. Using the versioned folder would fix the reported NuGet upgrade scenario, but MicrosoftTestingPlatformMSBuildTaskFolder is overridable and can point to a stable local path whose DLL changes in place. The regression test intentionally covers that case.

The DLL is only ~165 KiB and hashing it costs roughly 0.5 ms, once per relevant project build. We therefore prefer the content hash because it provides reliable invalidation without relying on package-layout or timestamp assumptions.

@Evangelink

Copy link
Copy Markdown
Member Author

/backport to rel/4.3

@github-actions

Copy link
Copy Markdown
Contributor

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

Labels

state/needs-review Awaiting review from the team.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stale source generated files on MSTest.Sdk update.

5 participants