Skip to content

Incremental builds: Respect inputs closure changes as well as timestamps #2470

@dasMulli

Description

@dasMulli

Currently targets are skipped based on the timestamps of files defined as inputs and outputs for the target. This is good and fast, yet maybe incorrect for what the target author intended.

Especially with the increased popularity of globbing to add items to projects, these items alone cannot be used as only inputs for incremental builds in some situations which may be unexpected for target authors. For example, when items are deleted or renamed, there is no newer modification timestamp, so a target may be skipped. Previously, the main project was modified when new items were added to the project so all targets using $(MSBuildAllProjects) as input would be rebuilt, but with globbing and an @(Compile) or @(Content) input, a target may be skipped unexpectedly.

Proposal: Add a new attribute to targets to allow target authors to opt into a new tracking of the input closure, so that given File1, File2 and File3 existed on disk with equal timestamps, a change of inputs from File1;File2 to File2;File3 will cause the target to be rebuilt.

I don't have a good idea how to name it though (TrackClosureForIncrementalBuilds="true"?).

The only workaround tat the moment would be to have an additional target write a file with all the inputs using MSBuild 15's <WriteLinesToFile WriteOnlyWhenDifferent="True" …/> feature and using the resulting file as input for incremental builds.

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-designRequires discussion with the dev team before attempting a fix.triaged

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions