【问题标题】:Cannot update nuget package (PCL)无法更新 nuget 包 (PCL)
【发布时间】:2018-02-20 14:51:05
【问题描述】:

在 Android 中使用地图时出现此错误:

System.MissingMethodEsception: Method
'Xamarin.Forms.maps.Android.MapRenderer.OnCameraChange' not found.

我读到你可以更新 nugetpackage 来解决这个问题。但是,由于这个原因,我无法安装它:

Could not install package 'TK.CustomMap 2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', 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.

软件包安装更新仅适用于 iOS 和 Android,但不适用于 PCL。我尝试删除所有包,然后尝试添加 TK.Customs nuget 包,但同样的问题。

还尝试将它安装在一个新项目上,并且安装得很好。只是无法将它安装在我的旧项目上。

这是尝试更新软件包时的完整错误消息:

 Attempting to gather dependency information for package 'TK.CustomMap.2.0.1' with respect to project 'Vernamo', targeting '.NETPortable,Version=v4.5,Profile=Profile78'
  GET https://api.nuget.org/v3/registration3-gz-semver2/tk.custommap/index.json
  OK https://api.nuget.org/v3/registration3-gz-semver2/tk.custommap/index.json 175ms
Total number of results gathered : 29
Gathering dependency information took 232 ms
Summary of time taken to gather dependencies per source :
https://api.nuget.org/v3/index.json -   204.03 ms
Attempting to resolve dependencies for package 'TK.CustomMap.2.0.1' with DependencyBehavior 'Lowest'
Resolving dependency information took 0 ms
Resolving actions to install package 'TK.CustomMap.2.0.1'
Resolved actions to install package 'TK.CustomMap.2.0.1'
Found package 'TK.CustomMap 2.0.1' in '/Users/holger/Downloads/Vernamo/packages'.
For adding package 'TK.CustomMap.2.0.1' to project 'Vernamo' that targets 'portable45-net45+win8+wp8'.
Install failed. Rolling back...
Package 'TK.CustomMap.2.0.1' does not exist in project 'Vernamo'
Executing nuget actions took 52 ms
Could not install package 'TK.CustomMap 2.0.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile78', 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.

【问题讨论】:

标签: c# android xamarin xamarin.forms visual-studio-2017


【解决方案1】:

TK.CustomMap 的预发布版本(至少 pre2)支持所有平台(参见 here),无论如何,截至 pre3(参见here),显然放弃了对所有平台的支持,转而支持 .NET Standard(在这种情况下为 1.1)。

您在 PCL 中使用的配置文件似乎与 .NET Standard 1.1 不兼容,因此 NuGet 无法添加引用。您可以尝试切换到另一个配置文件(例如 .NET 4.5.1),但我不知道这是否会有所帮助。另一种选择是将您的项目迁移到 .NET Standard。这是一种愚蠢的、重复性的任务,但这是可能的。

【讨论】:

  • 如果我将项目设为 .Net 标准。它可能会影响其他包和代码,对吗? @Paul Kertscher
  • @petterandersson 是的,理论上它可能会影响代码,但是使用 .NET Standard 2.0,您应该能够使用比 PCL 更多的 .NET Framework。无论如何,您当然必须彻底测试。
  • @petterandersson AFAIK,如果您使用的是 .NET Standard 2.0,您应该能够使用所有 4.5 和 4.5.1 PCL,因此这应该不是问题。我刚刚将一个中型代码库移植到 .NET Standard,它仍然可以正常工作。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-06-27
  • 1970-01-01
  • 1970-01-01
  • 2018-06-27
  • 2016-11-14
  • 1970-01-01
  • 2018-10-22
相关资源
最近更新 更多