gpt4 book ai didi

nuget - 无法更新或安装包 : An item with the same key has already been added

转载 作者:行者123 更新时间:2023-12-04 01:48:45 24 4
gpt4 key购买 nike

问题

在特定项目中,我无法更新或安装任何 NuGet 包。当我尝试使用 NuGet GUI 执行此操作时,它会执行一些操作,然后停止而什么也没说。当我尝试使用包管理器控制台执行此操作时,我得到以下输出:

PM> Update-Package –reinstall EntityFramework
Attempting to gather dependencies information for multiple packages with respect to project 'SmartCentre', targeting '.NETFramework,Version=v4.5.2'
Update-Package : An item with the same key has already been added.
At line:1 char:15
+ Update-Package <<<< –reinstall EntityFramework
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand

环境
  • Visual Studio Professional 2015 更新 1
  • NuGet 3.3.0.167

  • 我试过的
  • 删除 packages文件夹
  • 重新启动 Visual Studio
  • 重启电脑
  • 最佳答案

    原来是packages.config文件有几个不同版本的重复项:

    <?xml version="1.0" encoding="utf-8"?>
    <packages>
    <!-- ... -->
    <package id="Microsoft.AspNet.Web.Optimization" version="1.0.0" targetFramework="net40" />
    <package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net40" />
    <!-- ... -->
    <package id="Newtonsoft.Json" version="4.5.11" targetFramework="net40" />
    <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" />
    <!-- ... -->
    </packages>

    一旦我删除了重复项,问题就会停止发生:
    <?xml version="1.0" encoding="utf-8"?>
    <packages>
    <!-- ... -->
    <package id="Microsoft.AspNet.Web.Optimization" version="1.1.2" targetFramework="net40" />
    <!-- ... -->
    <package id="Newtonsoft.Json" version="5.0.8" targetFramework="net40" />
    <!-- ... -->
    </packages>

    关于nuget - 无法更新或安装包 : An item with the same key has already been added,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34844765/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com