Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add reference from C# PCL to F# PCL (VS 2015 Update 1)

I have problems creating F# portable project which than should be referenced from C# portable project. When adding such reference, the following message appears:

Unable to add a reference to 'PortableLibrary1'. Portable Library projects can only reference other Portable Library projects and assemblies.

The problem is easily reproduced using latest Visual Studio 2015 Update 1 (version 14.0.24720.00). I also have Xamarin installed.

I can reproduce the problem using any kind of C# portable project with following available:

  • Class Library (Portable)
  • Class Library (Portable for iOS, Android and Windows)

and with any kind of F# portable library project with following available:

  • Portable Library (.NET 4.5, Windows Store, Silverlight 5, Xamarin) [Profile 47]
  • Portable Library (.NET 4.5, Windows Store, Windows Phone 8 Silverlight, Xamarin) [Profile 78]
  • Portable Library (.NET 4.5, Windows Store, Windows Phone 8.1, Windows Phone Silverlight 8, Xamarin) [Profile 259]
  • Portable Library (.NET 4.5, Windows Store, Xamarin) [Profile 7]

I've used the same profiles for C# as for F# and nothing helps.

Seems like there already was a such issue before (How do I add a reference to F# Portable Library from C# Portable Class Library (PCL)) which then was successfully fixed. But it is now reproduced again.

Can somebody please tell me am I missing something? Maybe there is something which needs to be additionally installed or so?

like image 750
Anatoliy 'TLK' Kolesnick Avatar asked Jan 16 '16 14:01

Anatoliy 'TLK' Kolesnick


1 Answers

I just had the same issue. I solved it with hacking the .csproj of my PCL. After that the F# PCL is referenced in the C# project and I can use everything. I don't know if there are any problems - I could not figure out any.

Here are the steps to reproduce:

  • new C# project (portable class profile 111)
  • new F# project (portable class profile 7)
  • look into F# .fsproj file and copy value of "Project/PropertyGroup/ProjectId"
  • edit C# .csproj and add following itemgroup

    <ItemGroup>
        <ProjectReference Include="..\F# Project\F# Project.fsproj">
            <Project>{F# Project Id}</Project>
            <Name>F# Project</Name>
        </ProjectReference>
    </ItemGroup>
    

I'm using Visual Studio 2015 Community with Update 2

like image 193
Matt Avatar answered Oct 13 '22 14:10

Matt