简体   繁体   中英

Consuming packages from Xamarin projects

I'm trying to make Npgsql, the PostgreSQL provider for .NET, available for consumption by Xamarin users. I've explored various methods for doing this and seem to be blocked.

First, a Xamarin project can consume packages which target certain PCL profiles. The problem is that none of of these PCL profiles contain System.Data, which Npgsql requires, even though Xamarin itself allows you to use System.Data .

Second, Npgsql already supports the .NET Platform Standard (version 3), and the documentation on the standard contains the following sentence:

If a library targets .NET Platform Standard version 1.3, it can only run on .NET Framework 4.6 or later, .NET Core, Universal Windows Platform 10 (UWP), and Mono/Xamarin platforms.

However, trying to go down this path yielded several errors ( this question is one of them ). My guess is that the Xamarin tooling isn't yet fullynetstandard-aware.

Finally, it seems possible to import Npgsql as a shared project inside the user's solution, but this seems like a very hacky and wrong solution - it bypasses NuGet entirely.

Does anyone have any info on this?

I believe your speculation is correct of Xamarin tooling not being fully netstandard /PCL5 aware AFAIK(Your speculation is as good as mine). This is a huge effort by all parties involved to be unified. There have also been significant changes on the dotnet end that can alter this.

For your questions about System.Data :

System.Data is missing a bit of functionality: https://developer.xamarin.com/guides/ios/advanced_topics/system.data/#Missing_Functionality

System.Data is available via the Xamarin.iOS.dll assembly as it's not supported in PCLs.

https://developer.xamarin.com/guides/ios/under_the_hood/assemblies/

https://msdn.microsoft.com/en-us/library/system.data(v=vs.110).aspx (Notice no PCL items inside)

Finally, there should be a blog post next week about netstandard via https://blogs.msdn.microsoft.com/dotnet/2016/05/23/changes-to-project-json/

I would highly recommend that you join the .NET core slack channel to ask any questions you may have.

http://tattoocoder.com/aspnet-slack-sign-up/

That npgsql package seems to be depending on pre-release packages (RC - Release Candidate). Run the install with -pre option:

Install-Package npgsql -pre

This worked at least when installing to an iOS project. Not sure if it functions correctly as none of the dependencies are added to the References, only Npgsql.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM