使用framework 4.0安装nuget包Google.Apis.Driver.v3



几周前,我正在处理一个项目,打开Package Manager控制台运行命令Install-Package Google.Apis.Drive.v3。一切似乎都很顺利,没有任何问题。。。但今天,当我尝试这样做时,我收到了一个错误,告诉我这个包不支持Framework 4.0!

PM> Install-Package Google.Apis.Drive.v3
Attempting to resolve dependency 'Google.Apis (≥ 1.11.1)'.
Attempting to resolve dependency 'Google.Apis.Core (≥ 1.11.1)'.
Attempting to resolve dependency 'Microsoft.Bcl (≥ 1.1.10)'.
Attempting to resolve dependency 'Microsoft.Bcl.Build (≥ 1.0.14)'.
Attempting to resolve dependency 'Microsoft.Bcl.Async (≥ 1.0.168)'.
Attempting to resolve dependency 'Microsoft.Net.Http (≥ 2.2.29)'.
Attempting to resolve dependency 'Newtonsoft.Json (≥ 7.0.1)'.
Attempting to resolve dependency 'Zlib.Portable.Signed (≥ 1.11.0)'.
Attempting to resolve dependency 'Google.Apis.Auth (≥ 1.11.1)'.
Installing 'Microsoft.Net.Http 2.2.29'.
You are downloading Microsoft.Net.Http from Microsoft, the license agreement to which is available at http://go.microsoft.com/fwlink/?LinkId=329770. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Microsoft.Net.Http 2.2.29'.
Installing 'Newtonsoft.Json 7.0.1'.
Successfully installed 'Newtonsoft.Json 7.0.1'.
Installing 'Google.Apis.Core 1.11.1'.
Successfully installed 'Google.Apis.Core 1.11.1'.
Installing 'Zlib.Portable.Signed 1.11.0'.
You are downloading Zlib.Portable.Signed from AdvancedREI,  onovotny, the license agreement to which is available at http://en.wikipedia.org/wiki/Zlib_License. Check the package for additional dependencies, which may come with their own license agreement(s). Your use of the package and dependencies constitutes your acceptance of their license agreements. If you do not accept the license agreement(s), then delete the relevant components from your device.
Successfully installed 'Zlib.Portable.Signed 1.11.0'.
Installing 'Google.Apis 1.11.1'.
Successfully installed 'Google.Apis 1.11.1'.
Installing 'Google.Apis.Auth 1.11.1'.
Successfully installed 'Google.Apis.Auth 1.11.1'.
Installing 'Google.Apis.Drive.v3 1.11.1.434'.
Successfully installed 'Google.Apis.Drive.v3 1.11.1.434'.
Adding 'Microsoft.Net.Http 2.2.29' to Drilyser.
Successfully added 'Microsoft.Net.Http 2.2.29' to Drilyser.
Adding 'Newtonsoft.Json 7.0.1' to Drilyser.
Successfully added 'Newtonsoft.Json 7.0.1' to Drilyser.
Adding 'Google.Apis.Core 1.11.1' to Drilyser.
Uninstalling 'Google.Apis.Core 1.11.1'.
Successfully uninstalled 'Google.Apis.Core 1.11.1'.
Uninstalling 'Newtonsoft.Json 7.0.1'.
Successfully uninstalled 'Newtonsoft.Json 7.0.1'.
Uninstalling 'Microsoft.Net.Http 2.2.29'.
Successfully uninstalled 'Microsoft.Net.Http 2.2.29'.
Install failed. Rolling back...
Install-Package : Could not install package 'Google.Apis.Core 1.11.1'. You are trying t
o install this package into a project that targets '.NETFramework,Version=v4.0', but th
e 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:16
+ Install-Package <<<<  Google.Apis.Drive.v3
    + CategoryInfo          : NotSpecified: (:) [Install-Package], InvalidOperationExc 
   eption
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands. 
   InstallPackageCommand

我在VS2010中开发并使用Framework 4.0。所以我需要这个软件包来安装在我的环境中。在过去几周内发布的版本中,他们是否可能将软件包更改为仅支持4.5+?你知道我该怎么解决这个问题吗?

我的目标是访问Google Drive API,并能够遵循此处的示例。

请参阅:https://www.nuget.org/packages/Google.Apis/。支持的平台指定为.Net Framework 4.5

最新版本的Drive API.v3仅支持.Net Framework 4.5

如果您真的需要在.Net Framework 4.0中使用它,那么我建议您安装该软件包的早期版本
Google.Apis.Drive.v3 Client Library 1.10.0.130似乎同时支持.Net 4.0.Net 4.5

使用此命令安装此特定版本的

Install-Package Google.Apis.Drive.v3 -Version 1.10.0.130

如果此版本不起作用,请尝试以前的版本。希望这能有所帮助。

自2016年3月22日起,对.Net Framework 4.0的Google.Net客户端库v1.11版本的支持已停止(请参阅#696)。

Nuget-Get软件包目前在尝试将其安装在.Net 4.0项目上时存在问题,它应该下载不再支持或基于软件包开发的旧软件包。它不起作用,解决办法是自己下载以前的v1.10版本。(链接)

或者,您可以将项目升级到.net framework 4.5,并使用库中受支持的部分。

更新:

如果您选择继续使用.Net 4.0版本的库,请注意不会有进一步的更新。这不仅在核心库中,而且在所有生成的API库中。如果您正在使用的API发布或更改任何内容,您将不会得到任何这些更改。

Install-Package Google.Apis.Drive.v3 -Version 1.10.0.130

我想你说的是这个包:Google.Apis.drive.v3正如你所看到的,它支持以下平台:

**Supported Platforms:**
 - .NET Framework 4.5
 - Windows Store apps
 - Windows Phone 8 and 8.1
 - Portable Class Libraries

所以它不支持4.0,请升级它。

相关内容

最新更新