xamarin - 如何在NET标准项目中使用nuget包,该包仅兼容portable-net45+win8+wp8+wpa81?

标签 xamarin nuget mobile-center visual-studio-app-center

上下文

经过几个小时的无聊工作,我刚刚将 Xamarin.Forms 解决方案中的所有 PCL 项目迁移到 .NET 标准。 (为什么?因为当时这似乎是个好主意)

无论如何,我已经成功了。

下一步我决定添加 Xamarin Insights,我被定向到 https://mobile.azure.com/我在其中指示使用 Microsoft.Azure.Mobile.Analytics 和 Microsoft.Azure.Mobile.Crashes 包。

但是,在安装任何软件包时,我收到此错误:

Package Microsoft.Azure.Mobile.Analytics 0.15.0 is not compatible with netstandard1.4 (.NETStandard,Version=v1.4). Package 
Microsoft.Azure.Mobile.Analytics 0.15.0 supports:
 - monoandroid403 (MonoAndroid,Version=v4.0.3)
 - portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)
 - uap10.0 (UAP,Version=v10.0)
 - xamarinios10 (Xamarin.iOS,Version=v1.0)

问题

我理解这个错误。请不要告诉我必须将所有项目再次迁移回 PCL。 (并放弃 .NET 标准)。

我有一些内存,在某处读到有一个神奇的软件包,我安装了它,然后它提供了一些技巧,一切都会再次变得很酷。 (还是我在做梦?)

最佳答案

您可以向项目配置添加后备,以在 PCL 项目中使用 .NET 标准包:

新的 csproj 格式:

<PropertyGroup>
  <PackageTargetFallback>portable-net45+win8+wpa81</PackageTargetFallback>
</PropertyGroup>

旧的project.json格式:

 "frameworks": {
   "netstandard1.4": {
     "imports": "portable-net45+win8+wpa81"
   }
 }

至于“神奇”包,您可能被告知 Microsoft.Bcl.Build但在这种情况下,我不确定它是否有帮助。

关于xamarin - 如何在NET标准项目中使用nuget包,该包仅兼容portable-net45+win8+wp8+wpa81?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46285734/

相关文章:

c# - Xamarin Forms 没有为 UITest 设置 StyleId

android - 正确的配置更改处理

c# - 应用程序在后台关闭

c# - 为什么 ReactiveUI 依赖旧版本的 System.Reactive?

.net - Ninject 的 InRequestScope 发生了什么

visual-studio - 使用EnvDTE自动化Visual Studio时确定Package Manager控制台已准备就绪

android - 当我尝试将 mobile-center-push 添加到 React Native 项目时找不到 com.google.firebase :firebase-core:11. 0.0

xamarin.android - Mobile Center 是 Xamarin Build 失败并出现 pthread_mutex_lock 错误

uwp - 使用 VSTS 任务将 UWP 应用分发到应用中心(又名移动中心)

android - 更新到 Xamarin.Forms 2 后生成错误