F# PCLs in XS 5.5.4 & VS 2013

Hi,

The short version: How do I reference a PCL project, Profile 78, in Xamarin Studio (XS), created in Visual Studio 2013?

The long version:

  1. I create a F# PCL Profile project in VS: New Project -> Portable Library (.NET 4.5, ...)

  2. The in XS, I add this project to my solution and try to reference it from an Androind F# Project.

  3. In the project references list, in XS, the project is grayed out: "Incompatible target framework: .NETFramework, Version=v4.5, Profile=Profile78"

  4. In the PCL project in XS, the project properties under target framework says: ".netframework 4.5 prof 78 (not installed)".

What am I missing? I've gathered some bits and pieces stating that it should be possible. But nowhere is there clear documentation on how to achieve this.

Thanks for your help

Posts

  • mattwardmattward GBMember Xamurai
    edited December 2014

    From the error messages it looks like Xamarin Studio is not finding the Portable Class Libraries on your machine.

    Does the following file exist on your machine?

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\RedistList\FrameworkList.xml
    

    Also do you have a Xamarin.Android.xml file in the following directory?

    C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETPortable\v4.5\Profile\Profile78\SupportedFrameworks
    

    Also can you check that your PCL Project's target framework is not set to 4.0? In the .csproj file if the TargetFrameworkVersion is 4.0 then Xamarin Studio will say that the PCL profile is not found. It should be 4.5

    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
    
  • Hi Mattward,

    Thank you for your suggestions. I appreciate the help.

    I checked them, and have all of those. Personally at this stage I have a suspicion that it's got something to do that I'm using F#, instead of C#.

  • DaveThomasDaveThomas GBMember, Xamarin Team Xamurai

    @JacquesduPreez‌ Are you trying to reference the pcl78 project as a project reference or a file reference?

  • @DaveThomas,

    Good question. Referencing it as a project reference...

    Thanks

  • DaveThomasDaveThomas GBMember, Xamarin Team Xamurai

    @JacquesduPreez‌ There is a difference between the way VS and XS treat pcl assemblies. XS uses the PCL project type guid to determine if the project reference can be added:

    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB}</ProjectTypeGuids>

    C# projects use this to display the appropriate PCL dialogs to determine which profile you want to use via the dropdown selection. In Visual studio F# project have no such user interface (Initially there was only profile47 so no UI was needed), so if you add the project type guid you will get an error in VS. So currently the only solution is to include the project type guid, or use a file reference.

    If you are using VS2013 then the following would load in both XS and VS13:

    <ProjectTypeGuids Condition="'$(MinimumVisualStudioVersion)' == '12'">{786C830F-07A1-408B-BD7F-6EE04809D6DB}</ProjectTypeGuids>

  • DenisOkDenisOk FRMember

    Hi guys,

    I'm jumping in this thread as I had the same problem https://twitter.com/OkayX6/status/539230169194844160.

    @DaveThomas‌ Thanks! I could successfully reference it from my Android app, compile it and deploy it!

    Additional question (hope I doesn't highjack the thread too much): is it expected to do this trick for F# PCL in Xamarin? Is it normal that I am not offered the choice to create an F# PCL project from Xamarin (but only a regular library)?

    See screenshot:

  • DaveThomasDaveThomas GBMember, Xamarin Team Xamurai

    @DenisOk‌ Yeah, the reason its not offered is because of the complication I stated above, theres not an easy way to detect thats its XS thats running rather than VS, and VS/XS have different project guid behaviours. It would be good to get this resolved fully.

  • bansheebanshee USMember

    Could someone post a working .fsproj PCL file? I'm not completely following the changes necessary.

  • DavidYKayDavidYKay USMember

    @banshee : I've put together a brief blog post and an example on GitHub. I hope this helps.

  • DonHuffDonHuff USMember

    @DavidYKay Perfect example...thank you!

  • bansheebanshee USMember

    In Xamarin Studio 6.1, F# PCL is working straight out of the box, FYI.

  • bansheebanshee USMember

    In Xamarin Studio 6.1, F# PCL is working straight out of the box, FYI.

Sign In or Register to comment.