Rob Lyndon
Rob Lyndon

Reputation: 12661

F# .NET Standard Library Project

I have a Xamarin Forms solution, containing several F# portable class libraries.

In order to use the latest version (4.0.0) of Microsoft.Azure.MobileClient, I need to upgrade to FSharp.Core 4.2.1, but this appears to be incompatible with Profile 78:

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

It is possible to use .NET Standard class libraries from Xamarin projects, but is it possible to create a .NET Standard class library in F#?

What is the best way forward here?

Upvotes: 3

Views: 834

Answers (2)

Mirche Toshevski
Mirche Toshevski

Reputation: 1

You can try to convert your Xamarin.Forms (and your F#) project from .NET Portable to .NET Standard 2.0, since both packages can be added to .NET Standard.

How to convert Xamarin.Forms to .NET Standard

  • Create new Xamarin.Forms project (skip for already created project)
  • Create new .NET Standard library project in the same solution
  • Add reference to Xamarin.Forms package
  • Copy your content from Xamarin.Forms shared project to the new library project
  • Change all references (from Android, iOS, UWP) to point to the library project instead of the shared project

Source: Xamarin Blog

Upvotes: 0

Phillip Carter
Phillip Carter

Reputation: 5005

What the error message is telling you is that the project is targeting a PCL target. FSharp.Core 4.2.x does not have a PCL target anymore, and only contains .NET Framework and .NET Standard 1.6 binaries. Neither is compatible with the PCL target F# is using here.

The release notes for FSharp.Core were recently updated with developer guidance: https://www.nuget.org/packages/FSharp.Core/

This is the important bit for your project:

For existing packages targeting .NET Frameworks 4.0 or lower and PCLs, use FSharp.Core 4.1 or lower.

.NET Standard (as of this time) has not proliferated across all things .NET yet. As @Foole says, you can indeed create a .NET Standard class library with F# today. But it's not compatible with the rest of the .NET ecosystem until .NET Standard is fully supported on all flavors of .NET.

Upvotes: 2

Related Questions