我有一个项目,其中包含两个 F# 项目和一个 C# 项目,我想在其中编写一些 XUnit 测试:
- FS_PL:F# 3.1 (3.3.1.0) 可移植库
- FS_PL_Legacy:F# 31。(2.3.5.1) 可移植库(旧版)
- 测试:C# .NET 4.5/Win8 C# 可移植类库 (PCL)
我无法将测试中的引用添加到任一 F# 库。
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":
这很奇怪,因为我的测试和 FS_PL 库都配置为针对 .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'":
有谁知道我做错了什么?
部分解决方法 #1
使用 miegirl 的解决方法讨论这个问题的 Connect 问题 https://connect.microsoft.com/VisualStudio/feedback/details/761306/cannot-add-reference-to-portable-f-library-from-portable-c-library,我将以下内容添加到 C# 项目中:
<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>
这至少允许 VS 引用 F# 项目,但这些项目带有多个警告标记,并且 C# 可移植库无法构建,因为它无法引用一个或两个 F# 库中的类型:(
构建输出窗口中的大多数警告表明无法引用 F# 库,因为它们似乎“间接依赖于框架程序集“[System.Threading/System.Lync/etc.]”,无法在目前的目标框架"