The _MvcCopyDependencyFiles target does a couple things that make it take more time than necessary:
- The
DepsFilePaths Item Group is built up via batching, which is not ideal from a perf perspective
- The
Copy Task is invoked with Batching ("%(DepsFilePaths.FullPath)") which invokes the Task onces for each different item. This is very inefficient
- It's much more efficient to build up item lists for SourceFiles and DestinationFiles input parameters that explicitly map source to destination by matching position, and to alsp specify
SkipUnchangedFiles as true to prevent touching the files on every build, which also causes re-work.
This was found as part of a .NET 10-update analysis for the Copilot team. It's important to fix this (and #15295) because these Targets run for test projects, which are at the 'end' of the build - they are the long tail, and any time spent in them directly extends the overall time of the incremental build.