-
Notifications
You must be signed in to change notification settings - Fork 10.4k
[Infrastructure] Make npm restore and build incremental #62466
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Hey @dotnet/aspnet-build, looks like this PR is something you want to take a look at. |
I've made also build incremental. That cuts the build time for incremental builds ~600s on my box to ~350s |
</ItemGroup> | ||
|
||
<!-- Output files for incremental build check --> | ||
<ItemGroup> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How often might we have to update this list?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We haven’t changed anything in years I would say.
The list of outputs is not as important as the incrementalism is “all or nothing” for all the us projects.
MSBUILD requires at least one output or else it will not run the task.
The goal is that if you’re not touching the JavaScript. You don’t have to build any part of the JavaScript pipeline during your dev builds.
Implement incremental restore for npm workspace build system
Summary
This PR implements incremental build support for the npm restore process in the ASP.NET Core build system. The change adds proper input/output tracking to avoid unnecessary npm restore operations when node modules are already up-to-date, providing significant performance improvements during development.
Changes Made
Modified Npm.Workspace.nodeproj
Added Properties:
NpmWorkspaceRoot
: Points to the repository root for consistent path handlingNodeModulesMarkerFile
: Uses .package-lock.json as the restore completion markerAdded Input Files ItemGroup: Tracks all files that should trigger a restore when modified:
src/**/package.json
)Added Output Files ItemGroup: Uses npm's own marker file to determine restore completion
Enhanced Restore Target: Added
Inputs
andOutputs
attributes to enable MSBuild's incremental build logicPerformance Impact
Manual Testing Performed
Comprehensive testing was conducted to verify the incremental behavior works correctly across all input scenarios:
✅ Test Cases Verified
touch package.json
touch package-lock.json
touch src/SignalR/clients/ts/signalr/package.json
touch .npmrc
touch src/Components/Web.JS/package.json
✅ MSBuild Messages Verified
"Restoring NPM packages..."
"Skipping target 'Restore' because all output files are up-to-date with respect to the input files"
Technical Details
Inputs
andOutputs
target attributes.package-lock.json
file as the authoritative marker for restore completionBenefits