无法安装包 'Google.Apis.Core 1.13.1',无法卸载 'Microsoft.Bcl.Build 1.0.21'

Could not install package 'Google.Apis.Core 1.13.1', Unable to uninstall 'Microsoft.Bcl.Build 1.0.21'

我对 Google 日历 Api 有疑问。无法安装包 Google.Apis 和 Google.Apis.Auth,当 Install-Package Google.Apis.Calendar.v3 工作时。 .net 4.0 中的项目。

Install-Package : Unable to uninstall 'Microsoft.Bcl.Build 1.0.21' because 'Microsoft.Bcl 1.1.10' depends on it.
At line:1 char:1
+ Install-Package Google.Apis
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand


Install-Package : Could not install package 'Google.Apis.Core 1.13.1'. You are trying to install this package into a projec
t that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that
 are compatible with that framework. For more information, contact the package author.
At line:1 char:1
+ Install-Package Google.Apis.Auth
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationException
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand


PM> Install-Package Google.Apis.Calendar.v3
'Google.Apis.Calendar.v3 1.13.1.509' already installed.

无法解析主要引用 "Google.Apis.Calendar.v3, Version=1.13.1.509, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL",因为它间接依赖于无法在当前目标框架中解析的框架程序集 "System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"。 “.NETFramework,版本=v4.0”。要解决此问题,请删除引用 "Google.Apis.Calendar.v3, Version=1.13.1.509, Culture=neutral, PublicKeyToken=4b01fa6e34db77ab, processorArchitecture=MSIL" 或将您的应用程序重新定位到包含 "System.Net.Http, Version=1.5.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".

的框架版本

将您的项目升级到 .Net framework 4.5,它应该可以工作。错误消息会准确告诉您问题所在。

Could not install package 'Google.Apis.Core 1.13.1'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework.

如果您查看 NuGet 页面 Google APIs Core Client Library 1.13.1

The Google APIs Core Library contains the Google APIs HTTP layer, JSON support, Data-store, logging and so on.

Supported Platforms:

  • .NET Framework 4.5
  • Windows Store apps
  • Windows Phone 8 and 8.1
  • Portable Class Libraries

您必须返回 1.10 才能找到支持 Framework 4.0 的版本

Google.Net 客户端库的主页 GitHub