Optimize _MvcCopyDependencyFiles and _GeneratePublishTestManifest targets to reduce Copy task overhead#63994
Conversation
Co-authored-by: joperezr <[email protected]>
Co-authored-by: joperezr <[email protected]>
- Use new item list _DepsFilesToPublishResolved from FullPath metadata instead of overwriting _DepsFileToPublish - Change condition syntax from '@(list) != empty' to '@(list->Count()) > 0' to avoid list rendering overhead Co-authored-by: baronfel <[email protected]>
The existing functional tests in Would you like me to add specific integration tests that build test projects and verify the deps.json files are copied to the output directory? That would require setting up MSBuild-based integration tests similar to other SDK test infrastructure. |
There was a problem hiding this comment.
Pull Request Overview
This PR optimizes two MSBuild targets (_MvcCopyDependencyFiles and _GeneratePublishTestManifest) in the Mvc.Testing.targets file to reduce Copy task overhead and improve build performance, particularly for incremental builds.
- Eliminated batching overhead by replacing multiple Copy task calls with single Copy calls using item lists
- Added incrementality support through
SkipUnchangedFiles="true"to allow Copy tasks to skip unchanged files - Optimized condition syntax to use
Count()instead of string comparison to avoid unnecessary list rendering
_MvcCopyDependencyFilestarget in Mvc.Testing.targetsSkipUnchangedFiles="true"on the Copy task_GeneratePublishTestManifesttarget for consistencySummary
Optimized the
_MvcCopyDependencyFilesand_GeneratePublishTestManifesttargets in the Mvc.Testing.targets file to address performance issues during builds, especially incremental builds.Changes Made (Updated per review):
Eliminated batching overhead: Changed from batching-based Copy task calls (
%(...)) to building up item lists and making a single Copy call (@(...)). This reduces the number of Copy task invocations from N (where N = number of deps files) to 1.Added incrementality support: Added
SkipUnchangedFiles="true"to both Copy task calls. This allows the Copy task to internally manage incrementality, skipping files that haven't changed since the last build.Fixed item list handling: Use new item list
_DepsFilesToPublishResolvedpopulated from theFullPathmetadata instead of overwriting_DepsFileToPublish, preserving any downstream logic that depends on it.Optimized condition syntax: Changed from
'@(list)' != ''to@(list->Count()) > 0to avoid MSBuild rendering the entire list just to check if it's empty.Maintained all existing functionality: Preserved all existing properties including hard link and symbolic link support.
Expected Performance Impact:
Based on the issue description showing 2,321 seconds and 957 Copy task calls, the optimization should:
Original prompt
Fixes #63977
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.