更新NuGet软件包失败,并显示“错误:具有相同密钥的项目已被添加". [英] Updating NuGet package fails with "Error: An item with the same key has already been added"

查看:75
本文介绍了更新NuGet软件包失败,并显示“错误:具有相同密钥的项目已被添加".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近几周,我在尝试更新或删除NuGet软件包时注意到我们的几个解决方案存在问题:

In recent weeks I've been noticing an issue with a couple of our solutions, when trying to update or remove NuGet packages:

如果使用控制台,它也会失败:

It also fails if I use the console:

我不知所措.我碰到了一篇文章,建议在每个package.config文件中查找,以查看同一软件包是否可能被列出两次,但是它们都很好.另一篇文章建议删除所有软件包并重新安装,但是 如果可以的话,我宁愿不走那条路.

I'm at a loss to know where to look. I came across an article that suggested looking in each package.config files to see if the same package might be listed twice, but they are all fine. Another article suggested removing all packages and reinstalling, but I'd rather not go down that route if I can help it.

还有其他需要检查的想法吗?

Any ideas what else to check?

推荐答案

  安迪,

 Hi Andy,

欢迎访问MSDN论坛.

参考您的描述,我试图创建一个新项目并通过安装以前的NewtonSoft.Json软件包. Nuget Manager控制台,然后使用相同的命令:update-package NewtonSoft.Json进行更新,并成功升级到最新版本9.0.1,如以下屏幕截图所示,您能否在一个新项目中对其进行测试,看看是否与特定解决方案有关.

Refer to your description, I tried to create a new project and install a previous NewtonSoft.Json package through Nuget Manager Console, then use the same command: update-package NewtonSoft.Json to update and it successfully upgraded to the latest version 9.0.1 version like the following screenshot, could you please test it on a new project and see if this issue is relating to those specific solutions or not.

如果此问题优于那些特定解决方案,请按照错误消息具有相同键的项目已经添加",请看一看 此类似问题,并尝试以下解决此问题:

If this issue is prefer to those specific solutions, per the error message "An item with the same key has already been added", please have a look at this similar issue and have a try with the following to troubleshot this issue:

  1. 重新打开VS并重新加载该项目,然后清理,重建解决方案
  2. 更新Nuget ,请转到工具-扩展和更新…,如果有Nuget Package Manager的更新,请先安装它,然后重新打开VS.
  3. 检查解决方案浏览-参考和文件'packages.config',即解决方案存储文件夹的根文件夹下的'packages'文件夹,如果同一软件包的版本不同,则将其删除,然后修改 package.config文件以使用最新版本.
  4. 在解决方案"下,浏览并单击显示所有文件"图标,然后检查bin文件夹,请参见是否有对您尝试通过Nuget安装/更新的.dll的引用.找到后将其删除.
  1. Reopen VS and reload this project and clean, rebuild your solution
  2. Update Nuget, please go to Tools—Extensions and updates… and if there is update for Nuget Package Manager, please install it then reopen VS.
  3. Check Solution Explore--References and the file ‘packages.config’, the folder ‘packages’ that under root folder of the solution store folder, if there are different versions for the same packages, remove them then modify the package.config file to use the latest version.
  4. Under Solution Explore and click "Show All Files" icon and check the bin folder, see if there is any reference to the .dll that you try to install/update through Nuget or not. Remove it once you found.

最好的问候,

Sara


这篇关于更新NuGet软件包失败,并显示“错误:具有相同密钥的项目已被添加".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆