首页 > 解决方案 > Nuget:“Google.Apis”已经为“Google.Apis.Core”定义了一个依赖项

问题描述

尝试安装 package 时,我在 NuGet 中遇到以下错误Install-Package Google.Apis.Drive.v3 -Version 1.37.0.1470。显示以下错误:

Install-Package : 'Google.Apis' already has a dependency defined for 'Google.Apis.Core'.
At line:1 char:17
+ Install-Package <<<< Google.Apis.Drive.v3 -Version 1.37.0.1470
   + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
   + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

如果我安装以前的版本Install-Package Google.Apis.Drive.v2。也显示相同的错误:

Install-Package : 'Google.Apis' already has a dependency defined for 'Google.Apis.Core'.
    At line:1 char:17
    + Install-Package <<<< Google.Apis.Drive.v2
       + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
       + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

我正在使用 Visual Studio 2012、.net 框架 4.5 和 NuGet 包管理器 2.8.6031.8.667。请帮助我如何解决它。

标签: c#visual-studiowinformsinstallationnuget

解决方案


Nuget:“Google.Apis”已经为“Google.Apis.Core”定义了一个依赖项

由于您的 nuget 版本是2.8.6031.8.667,因此您可以安装的软件包的最高版本Google.Apis.Drive.v31.25.0.862

详细原因:

该软件包Google.Apis.Drive.v3具有以下依赖项列表:

Google.Apis.Drive.v3 (>= 1.37.0.1470)

                  ----Google.Apis (>= 1.37.0)

                             ----Google.Apis.Core (>= 1.37.0)

                                             ----Newtonsoft.Json (>= 10.0.2)

由于依赖包Newtonsoft.Json (>= 10.0.2)引入了 .netstandard 依赖:

在此处输入图像描述

这仅受 nuget 2.12及更高版本支持。那就是您收到该错误信息的原因,请在此处查看类似的线程。

因此,要解决此问题,请尝试安装较低版本的软件包版本Google.Apis.Drive.v3 1.25.0.862。我已经用我身边的 Visual Studio 2012 对其进行了测试,它工作正常。

此外,如果要安装该软件包的更高版本,则需要将 Visual Studio 更新到2013

希望这可以帮助。


推荐阅读