Skip to content
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

Visual Studio and PMC restore/update fails when multiple packages.config projects in the solution share the same name (An item with the same key has already been added) #13465

Closed
nkolev92 opened this issue May 28, 2024 · 1 comment · Fixed by NuGet/NuGet.Client#5825 or NuGet/NuGet.Client#5832
Assignees
Labels
Priority:1 High priority issues that must be resolved in the current sprint. Product:VS.Client Product:VS.PMConsole RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug
Milestone

Comments

@nkolev92
Copy link
Member

#13456

PM> Update-Package -reinstall
Update-Package : An item with the same key has already been added.
At line:1 char:1
+ Update-Package -reinstall
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Update-Package], ArgumentException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
 
PM> $error[0].Exception.StackTrace
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at NuGet.PackageManagement.PackageRestoreManager.<GetRestoreAuditProperties>d__31.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.PackageRestoreManager.<RestoreMissingPackagesAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.<CheckMissingPackagesAsync>d__64.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at NuGet.PackageManagement.PowerShellCmdlets.PackageActionBaseCommand.<<Preprocess>b__39_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.Threading.JoinableTask.CompleteOnCurrentThread()
   at NuGet.PackageManagement.PowerShellCmdlets.PackageActionBaseCommand.Preprocess()
   at NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand.Preprocess()
   at NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand.ProcessRecordCore()
   at NuGet.PackageManagement.PowerShellCmdlets.NuGetPowerShellBaseCommand.ProcessRecord()
@nkolev92 nkolev92 added Priority:1 High priority issues that must be resolved in the current sprint. Product:VS.Client Type:Bug Product:VS.PMConsole RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 labels May 28, 2024
@nkolev92 nkolev92 self-assigned this May 28, 2024
@nkolev92 nkolev92 changed the title Visual Studio and PMC restore/update fail with An item with the same key has already been added Visual Studio and PMC restore/update fails when multiple packages.config projects in the solution share the same name (An item with the same key has already been added) May 29, 2024
@Nevcairiel
Copy link

I've attached a very simple example to trigger the issue, the solution contains two projects with the same name, organized into folders, which allows to actually do this without getting errors from VS.

Just trying to build the project not in the sub-folder should grab NuGet dependencies, but it fails with the aforementioned error.

NuGetTestProject.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Priority:1 High priority issues that must be resolved in the current sprint. Product:VS.Client Product:VS.PMConsole RegressionFromPreviousRTM A regression from the last RTM. Example: worked in 6.2, doesn't work in 6.3 Type:Bug
Projects
None yet
3 participants