Skip to content

Do not count files written by projects outside the graph as leftover outputs - #199

Open
djack42 wants to merge 4 commits into
microsoft:mainfrom
djack42:upstream-pr/wpf-leftover-outputs
Open

djack42 wants to merge 4 commits into
microsoft:mainfrom
djack42:upstream-pr/wpf-leftover-outputs

Conversation

@djack42

@djack42 djack42 commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

Fixes case 3 of #192. Builds on #198: only the last commit is new here, the others are #198's. I'll rebase once #198 merges.

A project can build another project that is not a node of the graph, with the MSBuild task, into its own output directories. WPF markup compilation does this: it builds a temporary project (*_wpftmp.csproj) in the project's intermediate output directory, which writes the target framework moniker attribute file there. The project's own target that would write that file is then skipped as up to date, so the project only reads it.

The temporary project's file accesses are not attributed to any node. So on a build from empty output directories, the leftover-output check of #198 sees a file the project read but never wrote, and skips the node, in every build.

With SkipNodesWithLeftoverOutputs, the files written by projects that are not nodes of the graph are now recorded, and a file written during this build is not a leftover output. A file left by a previous build, which nothing writes in this build, still is.

Tests: two scenarios in tests/scenarios.ps1 mimic WPF with a generator project outside the graph, built with the MSBuild task, which writes a file into the node's intermediate output directory that the node only reads:

  • OutsideGraphWriteHit: the file is written by this build, so the node is added and the next build hits;
  • OutsideGraphLeftoverSkipped: the file is left over from a previous build and nothing writes it, so the node is still skipped.

🤖 Generated with Claude Code

djack42 and others added 4 commits November 27, 2026 10:17
The outputs of a project are the files it writes. When a project uses files left in its output directories (OutDir, IntermediateOutputPath) by a previous build without writing them, e.g. an incremental build whose targets were up to date, its outputs miss those files, and a cache hit in another clone would not place them.
With MSBuildCacheSkipNodesWithLeftoverOutputs (default false), such projects are not added to the cache. Their result is still used by their dependents in the build, so ICacheClient.AddNodeAsync takes a publish flag: the outputs are still hashed to build the node result, which is not added.
Existing probes are captured only when the setting is on, whether or not probe and enumeration fingerprinting is enabled.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Caching a project built over leftover outputs stores outputs without
the files it skipped, which a cache hit elsewhere would not place: a
correctness fix, so it is on by default. Setting
MSBuildCacheSkipNodesWithLeftoverOutputs to false still caches such
projects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The build summary only counted these nodes, while each one makes its dependents miss in every
build. Log the message at high importance, write it to notAdded.txt in the node log directory,
and name the other cause: a write by a process whose file accesses are not reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…outputs

A project may build another project which is not a node of the graph, with the MSBuild task, in its own output directories. WPF markup compilation builds a temporary project (*_wpftmp.csproj) in the project's intermediate output directory, which writes the target framework moniker attribute file there. The project's own target is then skipped as up to date, and the project only reads the file. The file accesses of the temporary project are not attributed to any node, so on a build from empty output directories the project was skipped as using a leftover output, and every later build missed.

With SkipNodesWithLeftoverOutputs, the files written by projects which are not nodes of the graph are recorded, and a file written in this build is not a leftover output. A file left by a previous build, which nothing writes in this build, is still one.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant