Skip to content

Design: Sort packages.lock.json dependencies by name#14763

Open
apoorvdarshan wants to merge 1 commit intoNuGet:devfrom
apoorvdarshan:design/sort-packages-lock-file-by-name
Open

Design: Sort packages.lock.json dependencies by name#14763
apoorvdarshan wants to merge 1 commit intoNuGet:devfrom
apoorvdarshan:design/sort-packages-lock-file-by-name

Conversation

@apoorvdarshan
Copy link
Copy Markdown

Summary

  • Adds a design spec proposing alphabetical sorting by package name (within each dependency type group) when generating packages.lock.json
  • Reduces diff churn during Central Package Management (CPM) migration and ensures deterministic ordering across restores
  • The proposed code change is a single-line addition of .ThenBy(d => d.Id, StringComparer.OrdinalIgnoreCase) in PackagesLockFileBuilder.cs

Test plan

  • Verify existing PackagesLockFileFormatTests pass with the ordering change
  • Validate that lock file round-trip (parse → write → compare) produces stable output
  • Confirm IsLockFileStillValid() is unaffected since it uses dictionary lookups, not list order

Addresses #14115

Proposes adding alphabetical sorting by package name as a secondary
sort key when generating packages.lock.json, reducing diff churn
during CPM migration and ensuring deterministic ordering.

Addresses NuGet#14115
@apoorvdarshan apoorvdarshan requested a review from a team as a code owner February 17, 2026 20:39
@dotnet-policy-service dotnet-policy-service bot added the Community PRs (and linked Issues) created by someone not in the NuGet team label Feb 17, 2026
@dotnet-policy-service dotnet-policy-service bot added the Status:No recent activity No recent activity. label Mar 20, 2026
@dotnet-policy-service
Copy link
Copy Markdown
Contributor

This PR has been automatically marked as stale because it has no activity for 30 days. It will be closed if no further activity occurs within another 330 days of this comment. If it is closed, you may reopen it anytime when you're ready again, as long as you don't delete the branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs (and linked Issues) created by someone not in the NuGet team Status:No recent activity No recent activity.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants