Skip to content

Re-run WriteVerifyAttributes when the values change - #1891

Merged
SimonCropp merged 2 commits into
mainfrom
fix-write-attributes-cache
Aug 30, 2026
Merged

Re-run WriteVerifyAttributes when the values change#1891
SimonCropp merged 2 commits into
mainfrom
fix-write-attributes-cache

Conversation

@SimonCropp

Copy link
Copy Markdown
Member

The up-to-date check compared only $(MSBuildAllProjects) timestamps against the generated file, but the content comes from $(SolutionDir), $(SolutionName) and $(TargetFrameworks). So rebuilding with a different /p:SolutionDir or /p:SolutionName, which is exactly what the DiscoverSolutionInfo warnings tell users to pass, or building the same project from another solution, skipped the target and CoreCompile and left stale metadata in the assembly for AttributeReader and DerivePaths to read at test time. Only a full Rebuild or touching the csproj cleared it.

The values are now written to a cache file with WriteOnlyWhenDifferent, and that file is an input, so its timestamp moves only on a real change. Same pattern as the SDK's GenerateAssemblyInfo.

Verified by building, then rebuilding with /p:SolutionName=OtherSolution: before this the emitted Verify.SolutionName stayed at the old value, now it updates.

The up-to-date check compared only $(MSBuildAllProjects) timestamps against the
generated file, but the content comes from $(SolutionDir), $(SolutionName) and
$(TargetFrameworks). So rebuilding with a different /p:SolutionDir or
/p:SolutionName, which is exactly what the DiscoverSolutionInfo warnings tell
users to pass, or building the same project from another solution, skipped the
target and CoreCompile and left stale metadata in the assembly for AttributeReader
and DerivePaths to read at test time. Only a full Rebuild or touching the csproj
cleared it.

The values are now written to a cache file with WriteOnlyWhenDifferent, and that
file is an input, so its timestamp moves only on a real change. Same pattern as
the SDK's GenerateAssemblyInfo.

Verified by building, then rebuilding with /p:SolutionName=OtherSolution: before
this the emitted Verify.SolutionName stayed at the old value, now it updates.
@SimonCropp SimonCropp added this to the 33.0.0 milestone Aug 29, 2026
@SimonCropp
SimonCropp merged commit 8890b5c into main Aug 30, 2026
3 of 5 checks passed
@SimonCropp
SimonCropp deleted the fix-write-attributes-cache branch August 30, 2026 00:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant