You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
"An item with the same key has already been added" - when project graph has projectName == packageRef name (of same version) #6795
The problem occurs when a dll is referenced as a nuget package and as a project reference.
If there are 3 projects, Source, Intermediate and DoublyReferencedTarget
Then the problem will occur when Source has:
ProjectReference to project Intermediate
ProjectReference to project DoublyReferencedTarget
And 'Intermediate' has
PackageReference to project DoublyReferencedTarget.
Thus project DoublyReferencedTarget is referenced twice in two different ways, which creates this error.
I realise that this is a genuine error, but a better error message would be very useful. Some of our solutions contains 100's of projects (a bad idea I know), and it's just taken me a week to track down this problem.
Reacted by Horváth László, Lee Timmins, ThaShepherd, Yevhenii Khudyi, Nate McMaster, Kevin Petit, Kenny Nielsen, Andrius K, Ryan Wersal, Alexey Bevetskiy and 18 more
I am able to reproduce it with the demo repo. VS 2017 Ent 15.6.6
And we also have this issue, and it is a quite big problem here, I've spent days to solve it, but we were unable to. So any help (hotfix, workaround, etc...) would be appreciated.
This is insane to see such a problem exist for such a long time without any response or workaround provided by the Nuget team. As I still could confirm these issues exist (vs 2019, .net core 3.0 preview) the simple workaround is to change the version of a package you do reference in sources. With the new version, it should start working fine.
The issue appears to be that the same name+version pair is both a package and a project reference. If they had different versions, it would work, or if it was consistently a package or a project reference both times, I expect it would work.
My initial reaction is that the assets file might need to change to support this scenario, rather than being a simple bug to fix.
Activity
nkolev92 commentedon Apr 17, 2018
@ceddlyburge
I am unable to reproduce this with the latest 15.7 preview.
Which version of VS are you using?
laszlohorvath commentedon Apr 19, 2018
I am able to reproduce it with the demo repo. VS 2017 Ent 15.6.6
And we also have this issue, and it is a quite big problem here, I've spent days to solve it, but we were unable to. So any help (hotfix, workaround, etc...) would be appreciated.
ceddlyburge commentedon Apr 19, 2018
Hi there, I am on VS 2017 Professional 15.6.4
I also get the problem on the command line using nuget 4.3.0.4406, which in turn uses msbuild 15.6.82.30579
MisterJimson commentedon Nov 2, 2018
Running into this as well...
natemcmaster commentedon Nov 9, 2018
Ran into this as well with VS 15.9. Anyone found a solution?
Divided the test project into individual test projects per NugGet pro…
JosepBalague commentedon Feb 7, 2019
NuGet 4.9.2.5706 (nuget restore), msbuild version '15.9.21.664', VS2017 15.9.6 still failing. When this will be solved?
bdongus commentedon Apr 6, 2019
Nuget 4.9.3.5777, VS2017 15.9.11. This still is an issue.
thyn commentedon Apr 25, 2019
vs19 same issue
GraySerg commentedon Jul 8, 2019
VS 2019 same error
ivankarpey commentedon Jul 8, 2019
This is insane to see such a problem exist for such a long time without any response or workaround provided by the Nuget team. As I still could confirm these issues exist (vs 2019, .net core 3.0 preview) the simple workaround is to change the version of a package you do reference in sources. With the new version, it should start working fine.
zivkan commentedon Jul 10, 2019
I was able to reproduce the error. The exception is thrown here: https://github.com/NuGet/NuGet.Client/blob/3113c5ddf420ae0c9c34959108e127136c8f141e/src/NuGet.Core/NuGet.Commands/RestoreCommand/LockFileBuilder.cs#L152
The issue appears to be that the same name+version pair is both a package and a project reference. If they had different versions, it would work, or if it was consistently a package or a project reference both times, I expect it would work.
My initial reaction is that the assets file might need to change to support this scenario, rather than being a simple bug to fix.
47 remaining items
nkolev92 commentedon Feb 4, 2021
@erdembayar
Given that it's an implementation detail and a question to the team, let's continue the discussion on the PR instead.