Make CollectDeclaredReferences support incremental builds#139
Merged
Conversation
Split the single CollectDeclaredReferences target into a pipeline of four targets to enable MSBuild Inputs/Outputs incremental skip: 1. _PrepareCollectDeclaredReferences (always runs) — computes properties, filters item groups, hashes non-file inputs (item groups, properties) into a cache file via Hash + WriteLinesToFile WriteOnlyWhenDifferent, builds _CollectDeclaredReferencesInputs, registers AdditionalFiles. 2. CollectDeclaredReferences (incremental via Inputs/Outputs) — runs the task which always writes the raw .tsv output. 3. _StabilizeCollectDeclaredReferences (incremental) — copies the raw .tsv to a stable .tsv via ReadLinesFromFile + WriteLinesToFile with WriteOnlyWhenDifferent. The stable file is what the compiler sees as AdditionalFiles, so CoreCompile only re-runs when content actually changes (not on timestamp-only changes). 4. _EmbedReferenceTrimmerDiagnosticsInBinlog (AfterTargets=CoreCompile) — embeds the raw .tsv in binlog. Additional cleanups: - Remove unused MSBuildProjectFile task property - Simplify SaveDeclaredReferences to write directly via StreamWriter Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Splits
CollectDeclaredReferencesinto a multi-target pipeline with proper MSBuildInputs/Outputsso the target can be skipped when nothing has changed.Design
Four-target pipeline:
_PrepareCollectDeclaredReferences(always runs) — computes properties, filters item groups, hashes non-file inputs (Reference names, PackageReference IDs, IgnorePackageBuildFiles, TFM, RID, etc.) into a cache file viaHash+WriteLinesToFile WriteOnlyWhenDifferent. Builds_CollectDeclaredReferencesInputsfrom file-based inputs (assets file, resolved references) plus the cache file.CollectDeclaredReferences(incremental) — runs the task, always writes the raw.tsvoutput._StabilizeCollectDeclaredReferences(incremental) — copies raw to stable.tsvviaReadLinesFromFile+WriteLinesToFile WriteOnlyWhenDifferent. The stable file is passed to the compiler asAdditionalFiles, soCoreCompileonly re-runs when content actually differs. This follows the pattern Rainer Sigwald described for ref assemblies._EmbedReferenceTrimmerDiagnosticsInBinlog— embeds the raw.tsvin binlog afterCoreCompile.Incremental test results
Additional cleanups
MSBuildProjectFiletask propertySaveDeclaredReferencesto write directly viaStreamWriterSupersedes #136 with a more complete approach.