Add support for resolving multiple NuGet package references with version conflict resolution #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements support for resolving multiple NuGet package references in a single call, with automatic version conflict resolution following NuGet's standard resolution rules. This addresses the issue request to support resolving multiple references efficiently.
Problem
Previously, the
INuGetHelperinterface only supported resolving a single NuGet package at a time. When multiple packages needed to be resolved, callers had to:This was inefficient and error-prone, especially when dealing with complex dependency graphs.
Solution
Added a new method to
INuGetHelper:The implementation provides:
1. Automatic Version Resolution
Packages without specified versions automatically resolve to the latest stable version:
2. Version Conflict Resolution
When the same package is specified multiple times with different versions, the highest version is selected:
3. Transitive Dependency Management
Dependencies from all packages are collected and merged, with version conflicts resolved by selecting the highest minimum version required by any dependency. Top-level packages take precedence over transitive dependencies.
4. Efficient Parallel Resolution
All packages and their dependencies are resolved to assemblies in parallel for optimal performance.
Version Resolution Strategy
The implementation follows NuGet's standard version resolution rules:
Changes
Testing
All tests pass successfully:
Example Usage
This provides a more efficient and developer-friendly API for scenarios where multiple NuGet packages need to be resolved together, such as in script compilation or dynamic code generation scenarios.
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.