使用框架 4.0 安装 nuget 包 Google.Apis.Drive.v3

Installing nuget package Google.Apis.Drive.v3 with framework 4.0

几周前我在做一个项目,打开包管理器控制台 运行 命令 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 并能够遵循位于 here.

的示例

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

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

不支持4.0,请升级

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

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

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

更新:

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

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

参见: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

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