Forum Xamarin.Forms

Write platform specific code in a .NET Standard Library project?

LeloLelo Member ✭✭✭

I started out using a .NET Standard Library project - to which I intend to build a NuGet out of in the future. But I found myself needing to write platform specific code.

I have seen approaches of editing the csproj file here and here - to add more targets. And I have also seen the Multiplatform Library library project type.

But using Multiplatform I found a NuGet package breaking:

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

which assume is because the target with that library type becomes NETPortable instead of netstandard2.0.

Can I add more targets to the .NET Standard Library project by editing csproj to be able to write platform specific code - or will I have to use the Multiplatform library type - and delete the NuGets that are breaking? Is it possible to use .NET Standard and write platform specific code?

Best Answer

Answers

Sign In or Register to comment.