我按照这里的描述编译了CoreCLR和CoreFX。基本上可以,我可以编译和运行针对 CoreCLR 的 C# 代码。
下一步是尝试编译和运行 F# 代码。所以我在项目中添加了FSharp.Core 3.1.2.1并使用以下命令编译了一个示例应用程序:
fsc ^
--noframework ^
--targetprofile:netcore ^
/r:packages\System.Runtime.4.0.20-beta-22703\lib\contract\System.Runtime.dll ^
/r:packages\System.Reflection.4.0.10-beta-22703\lib\contract\System.Reflection.dll ^
/r:packages\System.Collections.4.0.10-beta-22703\lib\contract\System.Collections.dll ^
/r:packages\System.Diagnostics.Debug.4.0.10-beta-22703\lib\contract\System.Diagnostics.Debug.dll ^
/r:packages\System.IO.FileSystem.4.0.0-beta-22703\lib\contract\System.IO.FileSystem.dll ^
/r:packages\System.Linq.Expressions.4.0.10-beta-22703\lib\contract\System.Linq.Expressions.dll ^
/r:packages\System.Console.4.0.0-beta-22703\lib\contract\System.Console.dll ^
/r:packages\System.Runtime.Extensions.4.0.10-beta-22703\lib\contract\System.Runtime.Extensions.dll ^
/r:packages\System.Runtime.InteropServices.4.0.20-beta-22703\lib\contract\System.Runtime.InteropServices.dll ^
/r:packages\System.Text.Encoding.4.0.10-beta-22703\lib\contract\System.Text.Encoding.dll ^
/r:packages\System.Text.RegularExpressions.4.0.10-beta-22703\lib\contract\System.Text.RegularExpressions.dll ^
/r:packages\System.Threading.Overlapped.4.0.0-beta-22703\lib\contract\System.Threading.Overlapped.dll ^
/r:packages\System.Threading.ThreadPool.4.0.10-beta-22703\lib\contract\System.Threading.ThreadPool.dll ^
/r:packages\FSharp.Core.3.1.2.1\lib\portable-net45+netcore45+MonoAndroid1+MonoTouch1\FSharp.Core.dll ^
/out:runtime\HelloWorld.exe HelloWorld.fs
如您所见,我是针对FSharp.Core的 Profile7 构建的。当我运行应用程序时,语句let test = sprintf "Hello, world"
失败并出现以下异常:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
at Microsoft.FSharp.Core.PrintfImpl.PrintfBuilderStack..ctor()
at Microsoft.FSharp.Core.PrintfImpl.PrintfBuilder`3..ctor()
at Microsoft.FSharp.Core.PrintfImpl.Cache`4.generate(String fmt)
at Microsoft.FSharp.Core.PrintfImpl.f@4277-43[T,TState,TResidue,TResult](String key, Unit unitVar0)
at Microsoft.FSharp.Core.PrintfImpl.Cache`4.get(String key)
at Microsoft.FSharp.Core.PrintfImpl.Cache`4.Get(PrintfFormat`4 key)
at Microsoft.FSharp.Core.PrintfModule.PrintFormatToStringThen[TResult,T](FSharpFunc`2 continutation, PrintfFormat`4 format)
at HelloWorld.main(String[] args)
我也在这里讨论过这个,但我不知道我做错了什么。我是否包含了错误版本的 FSharp.Core?Profile7应该可以工作。