I compiled CoreCLR and CoreFX as described here. Basically that works and I can compile and run C# code targeting CoreCLR.
The next step was to try compiling and running F# code. So I added FSharp.Core 3.1.2.1 to the project and compiled a sample application using the following command:
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
As you can see I built against Profile7 of FSharp.Core.
When I run the application the statement let test = sprintf "Hello, world"
fails with the following exception:
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)
I also discussed this here but I couldn't figure out what I am doing wrong. Did I include a wrong version of FSharp.Core? Profile7 should work.
At this time of writing (April 2015), F# has not yet been ported to fully support CoreCLR / CoreFX.
CoreCLR and CoreFX are currently undergoing a lot of changes and improvements while development proceeds. The churn will decrease and stability improve rapidly in the coming months, but building anything substantial on CoreCLR/FX at this time will be akin to building a skyscraper on quicksand.
Mono v.next, which is currently used to build and run F# on [LI|U]N[U|I]X, is also undergoing a lot of change as it replaces large chunks of the Mono platform and Framework with assemblies and code from CoreCLR and CoreFX.
You might want to track Visual F# issue #387 for progress.
You may also want to track Visual F# issue #336 which discusses supporting F# on CoreCLR for x-plat work.
Update1:
Now that F# 4.0 is shipped, the team are working on a bunch of new work: https://github.com/Microsoft/visualfsharp/issues/563
Key among those work items is adding CoreCLR support to F#: https://github.com/Microsoft/visualfsharp/issues/499.
来源:https://stackoverflow.com/questions/29798696/running-f-in-coreclr