如何为此PCL库制作NuGet软件包 [英] How to make a NuGet package for this PCL library

查看:42
本文介绍了如何为此PCL库制作NuGet软件包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

该nuget软件包旨在用于 Xamarin Forms 应用程序.因此,我什至不确定我所勾选的内容是否正确.

真的只关心.NET Framework4.这是的最低要求.至于其余的,我一点也不在乎,也不知道我应该瞄准什么.

对于它的价值,我正在使用

以及Xam Studio的错误消息:

 正在添加Foo ...在Core中添加"Foo 1.3.0".无法安装软件包"Foo 1.3.0".您正在尝试将此软件包安装到以'portable-net45 + win + wp80 + MonoTouch10 + MonoAndroid10 + xamarinmac20 + xamarinios10'为目标的项目中,但是该软件包不包含与该框架兼容的任何程序集引用或内容文件.有关更多信息,请与软件包作者联系. 

解决方案

对于Xamarin.Forms,可移植类库(PCL)项目使用的两个概要文件最好是概要文件78或概要文件259.Xamarin.Forms可以可以在其他配置文件中使用,但是如果您的PCL项目以这些配置文件中的一个为目标,则应该可以.您的项目看起来要针对配置文件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项目中.

I'm trying to create a nuget package for a PCL library I've made.

This nuget package is intended to be used in a Xamarin Forms application though. So I'm not even sure if the things I've ticked are correct.

I really only care about .NET Framework 4. That is my bare minimum framework. For the rest, I don't care at all and have no idea what I should be targetting.

For what it's worth, I'm using NuGet Package Explorer to create my NuGet nupkg files to manually test them before I publish them to NuGet.

Here's a screenshot of what I was trying, but Xamarin Studio failed to add the nuget package (saying it wasn't the right something-or-rather).

and the error message from 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.

解决方案

For Xamarin.Forms the two profiles that are good ones for your Portable Class Library (PCL) project to use are Profile 78 or Profile 259. Xamarin.Forms can be used in other profiles but if your PCL project targets one of these you should be OK. Your project looks to be targeting Profile 78.

Here are the Xamarin.Forms PCL profiles for reference.

Xamarin.Forms 1.3:

portable-win+net45+wp80+MonoAndroid10+MonoTouch10

Xamarin.Forms 1.4:

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

The problem with your NuGet package that it does not indicate that it supports Windows 8 in the PCL. NuGet will look at all the individual frameworks that make up the project's PCL profile (ignoring the Xamarin and Mono ones since they are optional if you do not have them in your NuGet package's PCL profile) and ensure that the NuGet package's PCL profile has a framework which is compatible. If the NuGet PCL does not have a matching framework then NuGet considers it incompatible.

So your NuGet package's portable library folder would need to include win

portable-net4+sl5+wp8+win

Then you can install your NuGet package into your Profile 78 PCL project.

这篇关于如何为此PCL库制作NuGet软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆