c# - 如何为此 PCL 库制作 NuGet 包

标签 c# .net xamarin nuget

我正在尝试为我制作的 PCL 库创建一个 nuget 包。

不过,此 nuget 包旨在用于 Xamarin Forms 应用程序。所以我什至不确定我勾选的内容是否正确。

真的只关心 .NET Framework 4。那是的最低限度框架。至于其他的,我根本不在乎,也不知道我应该瞄准什么。

为了它的值(value),我正在使用 NuGet Package Explorer创建我的 NuGet nupkg 文件,以便在将它们发布到 NuGet 之前手动测试它们。

这是我正在尝试的屏幕截图,但 Xamarin Studio 未能添加 nuget 包(说它不正确)。

enter image description here

以及来自 Xam Studio 的错误消息:

Adding Foo...
Adding 'Foo 1.3.0' to Core.
Could not install package 'Foo 1.3.0'. You are trying to install this package into a project that targets 'portable-net45+win+wp80+MonoTouch10+MonoAndroid10+xamarinmac20+xamarinios10', 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.

最佳答案

对于 Xamarin.Forms,两个适合您的可移植类库 (PCL) 项目使用的配置文件是配置文件 78 或配置文件 259。Xamarin.Forms 可用于其他配置文件,但如果您的 PCL 项目以其中之一为目标你应该没事。您的项目看起来是针对 Profile 78。

以下是供引用的 Xamarin.Forms PCL 配置文件。

Xamarin.Forms 1.3:

portable-win+net45+wp80+MonoAndroid10+MonoTouch10

Xamarin.Forms 1.4:

portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10 

您的 NuGet 包的问题在于它并未在 PCL 中指示它支持 Windows 8。 NuGet 将查看构成项目 PCL 配置文件的所有单独框架(忽略 Xamarin 和 Mono,因为如果您的 NuGet 包的 PCL 配置文件中没有它们,它们是可选的)并确保 NuGet 包的 PCL 配置文件具有框架这是兼容的。如果 NuGet PCL 没有匹配的框架,则 NuGet 认为它不兼容。

因此您的 NuGet 包的可移植库文件夹需要包含 win

portable-net4+sl5+wp8+win

然后您可以将 NuGet 包安装到您的 Profile 78 PCL 项目中。

关于c# - 如何为此 PCL 库制作 NuGet 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31953323/

相关文章:

c# - 隐藏用于 editText 焦点/触摸的软键盘

c# - C++/Java开发者在哪里可以找到C#的学习资料?

c# - 如何在 C# 中使用 return 语句打开 wpf 窗口

c# - 如何确定给定类型 (System.Type) 是否继承自特定基类(在 .Net 中)?

c# - WebView 中的 WebGL 在 UNO 构建中不起作用,但在 Xamarin 构建中起作用

c# - 为什么 Xamarin.Forms 在显示几个标签时如此缓慢(尤其是在 Android 上)?

c# - 即使集合没有改变,MVVM 从 ViewModel 刷新 Datagrid

c# - 以小时为单位显示两个日期时间值之间的差异

c# - 检查数组是否包含 false?

c# - GDI+ 图像比 C# 图像快得多