Skip to content

GenerateDepsFile Task should be internally-incremental #49349

@baronfel

Description

@baronfel

Is your feature request related to a problem? Please describe.

The GenerateDepsFile always writes a new deps.json file, even if the content is the same. This leads to rebuilds all down the target chain. We shouldn't write a deps.json unless the content would be materially different.

var writer = new DependencyContextWriter();
using (var fileStream = File.Create(depsFilePath))
{
writer.Write(dependencyContext, fileStream);
}
_filesWritten.Add(new TaskItem(depsFilePath));

using (JsonTextWriter writer = new(new StreamWriter(File.Create(fileName))))
{
serializer.Serialize(writer, value);
}

The recommended fast approach to this is to use XxHash64 to hash the existing file and the proposed content and compare. If they are the same, do not touch the existing file on disk in these two locations.

For future us: this and NuGet/Home#14355 were the cause of virtually all rebuilds in the internal repo binlog that Rainer and I investigated.

Metadata

Metadata

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions