Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Sep 24, 2025

  • Analyze the issue: dotnet workload search version shows duplicates when multiple feeds contain the same version
  • Identify root cause: Multiple feeds can return the same package version, causing duplicates in the output
  • Build the solution successfully to understand current state
  • Create focused test that reproduces the duplicate version issue
  • Updated approach per feedback: Move deduplication from NuGetPackageDownloader to WorkloadSearchVersionsCommand.GetVersions() to avoid side effects on other commands
  • Revert changes to NuGetPackageDownloader.cs and MockNuGetPackageDownloader.cs
  • Implement deduplication in WorkloadSearchVersionsCommand.GetVersions() method
  • Simplify resultsToRequest calculation per code review feedback
  • Verify fix works with existing and new tests
  • Run final validation and format code
  • Merge conflicts resolved: Merged with main branch, keeping only the two essential files with actual fix changes, discarding all formatting-only changes

Summary

Successfully merged with origin/main to resolve merge conflicts. The merge kept only the two files with actual functional changes:

  1. src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs - Contains the deduplication logic
  2. test/dotnet.Tests/CommandTests/Workload/Search/GivenDotnetWorkloadSearch.cs - Contains the test for duplicate detection

All other conflicted files (which only had formatting changes from the original PR) were resolved by taking the version from main, eliminating unnecessary formatting differences.

Fix Details:

  • Requests 2x the number of workload versions to account for potential duplicates from multiple NuGet feeds
  • Applies .Distinct() to remove duplicate versions
  • Maintains proper ordering with .OrderByDescending()
  • Returns the correct number of unique results after deduplication

Fixes #50979


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] dotnet workload search version shows duplicates if multiple copies found from different feeds Fix duplicate versions in dotnet workload search version when multiple feeds contain same version Sep 24, 2025
Copilot AI requested a review from marcpopMSFT September 24, 2025 17:14
@marcpopMSFT
Copy link
Member

@copilot I only want to impact the results from dotnet workload search version. Changing nugetpackagedownloader is too central and may have potential side effects for other commands that also use that file.

Copy link
Contributor Author

Copilot AI commented Oct 2, 2025

@copilot I only want to impact the results from dotnet workload search version. Changing nugetpackagedownloader is too central and may have potential side effects for other commands that also use that...

I've moved the deduplication logic from NuGetPackageDownloader to WorkloadSearchVersionsCommand.GetVersions() to avoid affecting other commands. The fix is now localized to workload search only. Changes in commit 1b4c9aa.

Copilot AI requested a review from marcpopMSFT October 3, 2025 18:53
@marcpopMSFT marcpopMSFT marked this pull request as ready for review October 6, 2025 21:46
@marcpopMSFT marcpopMSFT requested a review from a team as a code owner October 6, 2025 21:46
@marcpopMSFT marcpopMSFT requested review from Copilot and removed request for a team October 6, 2025 21:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug where dotnet workload search version would display duplicate versions when multiple NuGet feeds contained the same workload version. The fix implements deduplication logic directly in the WorkloadSearchVersionsCommand.GetVersions() method.

  • Deduplicates version results from multiple NuGet feeds while maintaining proper ordering
  • Requests more results than needed to account for potential duplicates, then filters to unique versions
  • Adds comprehensive test coverage for the duplicate version scenario

Reviewed Changes

Copilot reviewed 27 out of 87 changed files in this pull request and generated 2 comments.

File Description
src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs Implements deduplication logic and requests extra results to handle duplicates
test/dotnet.Tests/CommandTests/Workload/Search/GivenDotnetWorkloadSearch.cs Adds test case verifying no duplicate versions are shown
Multiple test files Reorganizes using statements for consistent formatting

@marcpopMSFT
Copy link
Member

Tested and reviewed. The copilot tried to run format on the files changed, got confused, and formatted the whole project. The full actual changes are in two files.
src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs
test/dotnet.Tests/CommandTests/Workload/Search/GivenDotnetWorkloadSearch.cs

Confirmed broken in rc1 and fixed in my local codespace:
image

@marcpopMSFT marcpopMSFT requested a review from baronfel October 6, 2025 21:51
@marcpopMSFT
Copy link
Member

@copilot can you fix the merge conflicts?

- Kept deduplication logic in WorkloadSearchVersionsCommand.GetVersions()
- Kept test for duplicate version handling
- Used main's version for all formatting-related conflicts
Copy link
Contributor Author

Copilot AI commented Dec 10, 2025

@copilot can you fix the merge conflicts?

Merge conflicts resolved in commit b243256. Kept only the two files with actual fix logic (WorkloadSearchVersionsCommand.cs and GivenDotnetWorkloadSearch.cs), discarded all formatting-only changes by using main's version for conflicted files.

@marcpopMSFT marcpopMSFT requested a review from nagilson December 12, 2025 23:49
@marcpopMSFT
Copy link
Member

@nagilson Got copilot to fix the merge conflicts. I tested this a while ago but never got a review. Most of the changes are formatting as this was before we had instructions on when to run formatting. The actual changes are in src/Cli/dotnet/Commands/Workload/Search/WorkloadSearchVersionsCommand.cs and test/dotnet.Tests/CommandTests/Workload/Search/GivenDotnetWorkloadSearch.cs

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

dotnet workload search version shows duplicates if multiple copies found from different feeds

2 participants