我一直在寻找fsharp编译器源代码来尝试构建一个wp7版本的FSharp.Core(FSharp.Core for Windows Phone 7.1 and F# 3.0),有一次我放弃并开始尝试使便携版本工作用wp7代替。我将FX_NO_STRUCTURAL_EQUALITY
定义添加到portable-net4+sl4+wp71+win8
目标框架,这似乎是导致它在运行时无法工作的原因,并试图用我的自定义替换C:\Program Files (x86)\Reference Assemblies\Microsoft\FSharp\3.0\Runtime\.NETPortable
中的FSharp.Core.dll版。但是在Visual Studio中编译时出现了这个错误:
Warning 1 The primary reference "FSharp.Core" could not be resolved because it has an indirect dependency on the framework assembly "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile47". To resolve this problem, either remove the reference "FSharp.Core" or retarget your application to a framework version which contains "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets 1578 5 FSharp.Data.Portable
Warning 3 The primary reference "FSharp.Core" could not be resolved because it has an indirect dependency on the framework assembly "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile47". To resolve this problem, either remove the reference "FSharp.Core" or retarget your application to a framework version which contains "System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets 1578 5 FSharp.Data.Portable
Warning 2 The primary reference "FSharp.Core" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETPortable,Version=v4.0,Profile=Profile47". To resolve this problem, either remove the reference "FSharp.Core" or retarget your application to a framework version which contains "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089". C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets 1578 5 FSharp.Data.Portable
问题是VS2012附带的便携式FSharp.Core依赖于mscorlib.dll,System.dll和System.Core.dll这些程序集的便携式2.0.5.0版本,但我从源代码编译的那个取决于非便携式4.0.0.0版本。有没有人从源代码成功构建了便携版本?
答案 0 :(得分:1)
你可以做的是添加:
<OtherFlags>$(OtherFlags) --simpleresolution -r:"pathToTheCorrectmscorlib/mscorlib-runtime.dll" </OtherFlags>
到FSharp.Source.Targets
文件。在<DefineConstants>
元素之后执行此正确的文件。这应该导致编译阶段使用您指定的mscorlib
版本,而不是msbuild目标指定的默认版本。 (显然用正确的替换pathToTheCorrectmscorlib/mscorlib-runtime.dll
:))
答案 1 :(得分:1)
在经过几次更改https://github.com/ovatsus/fsharp
之后,将f4内的portable-net4 + sl4 + wp71 + win8目标编译成Profile88仍需要在运行时彻底测试,但