I have a project which contains two F# projects and a C# project in which I'd like to write some XUnit tests:
I am unable to add a reference from Tests to either of the F# libraries.
When I try to add a reference to FS_PL, I am presented with a dialog that states "Unable to add a reference to project 'FS_PL'. The targets of Portable Library project 'FS_PL' are not the same or compatible with the targets of the current Portable Library project":
This is odd since both my Tests and FS_PL libraries are configured to target .NET 4.5 & Windows 8.
So I created FS_PL_Legacy and tried adding a reference to it. Doing so gives me a very 'helpful' message stating "Unable to add a reference to project 'FS_PL_Legacy'":
Does anyone know what I am doing wrong?
Using miegirl's workaround from a Connect issue discussing this problem, I added the following to the C# project:
<ItemGroup>
<!-- Manually added reference to F# projects to overcome issue discussed here:
http://stackoverflow.com/questions/23111782/how-do-i-add-a-reference-to-f-portable-library-from-c-sharp-portable-class-libr
-->
<ProjectReference Include="..\FS_PL\FS_PL.fsproj">
<Project>{2c4b1776-3d34-4534-8520-8a1e6daa0e6e}</Project>
<Name>FS_PL</Name>
</ProjectReference>
<ProjectReference Include="..\FS_PL_Legacy\FS_PL_Legacy.fsproj">
<Project>{0d7b657c-906b-4448-ae64-2153a1fa910c}</Project>
<Name>FS_PL_Legacy</Name>
</ProjectReference>
</ItemGroup>
This at least allows VS to reference the F# projects, but those projects are tagged with several warnings and the C# portable library is unable to build as it cannot reference the types in one or both of the F# libraries :(
Most of the warnings in the build output window indicate that the F# libraries cannot be referenced as they appear to have "an indirect dependency on the framework assembly "[System.Threading/System.Lync/etc.]" which could not be resolved in the currently targeted framework"
Select “References” and then “New Reference”, or press “Ctrl+N” on your keyboard or click the “New Reference” button (a clipboard with a plus sign). Choose the appropriate reference type from the “Reference Type” drop-down menu.
Click where you want to insert the bibliography—usually at the end of the document. Click the Reference tab. Then, click Bibliography in the Citations & Bibliography group. From the resulting dropdown list, choose a bibliography.
Ask and ye shall be heard ...
I raised this issue on Twitter with Don Syme and some of the F# team. They confirmed that it was an issue they had a fix that was working its way through the release process.
I installed today's Visual F# daily build and I can confirm that this issue has been resolved!
Thanks to Don and the F# team for fixing this issue - I can now incorporate new F# code into my predominantly C# codebase & test suite ... and begin replacing chunks of our system with FAR less F# code than the equivalent C# ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With