@@ -2213,7 +2213,7 @@ type TcConfigBuilder =
22132213 useFsiAuxLib= false
22142214 implicitOpens=[]
22152215 includes=[]
2216- resolutionEnvironment= ReferenceResolver.CompileTimeLike
2216+ resolutionEnvironment= ResolutionEnvironment.EditingOrCompilation false
22172217 framework= true
22182218 implicitlyResolveAssemblies= true
22192219 referencedDLLs= []
@@ -2801,55 +2801,67 @@ type TcConfig private (data : TcConfigBuilder,validate:bool) =
28012801// This call can fail if no CLR is found (this is the path to mscorlib)
28022802member tcConfig.GetTargetFrameworkDirectories () =
28032803use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
2804- match tcConfig.clrRootwith
2805- | Some x->
2806- [ tcConfig.MakePathAbsolute x]
2807- | None->
2808- #if ENABLE_ MONO_ SUPPORT
2809- if runningOnMonothen
2810- [ let runtimeRoot = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2811- let runtimeRootWithoutSlash = runtimeRoot.TrimEnd( '/' , '\\' )
2812- let api = runtimeRootWithoutSlash+ " -api"
2813- let rootFacades = Path.Combine( runtimeRootWithoutSlash, " Facades" )
2814- let apiFacades = Path.Combine( api, " Facades" )
2815- match tcConfig.resolutionEnvironmentwith
2816- #if ! FSI_ TODO_ NETCORE
2817- // For F# Interactive code we must inly reference impementation assemblies
2818- | ReferenceResolver.RuntimeLike->
2819- yield runtimeRoot
2820- if Directory.Exists( rootFacades) then
2821- yield rootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2822- #endif
2823- | _ ->
2824- // The default FSharp.Core is found in lib/mono/4.5
2825- yield runtimeRoot
2826- if Directory.Exists( rootFacades) then
2827- yield rootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2828- // It's not clear why we would need to reference the 4.5-api directory.
2829- if Directory.Exists( api) then
2830- yield api
2831- if Directory.Exists( apiFacades) then
2832- yield apiFacades
2833- ]
2834- else
2804+ try
2805+ [
2806+ // Check if we are given an explicit framework root - if so, use that
2807+ match tcConfig.clrRootwith
2808+ | Some x->
2809+ yield tcConfig.MakePathAbsolute x
2810+
2811+ | None->
2812+ #if FSI_ TODO_ NETCORE// there is no really good notion of runtime directory on .NETCore
2813+ let runtimeRoot = Path.GetDirectoryName( typeof< System.Object>. Assembly.Location)
2814+ #else
2815+ let runtimeRoot = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
28352816#endif
2836- try
2837- [
2838- match tcConfig.resolutionEnvironmentwith
2839- #if ! FSI_ TODO_ NETCORE
2840- | ReferenceResolver.RuntimeLike->
2841- yield System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory()
2817+ let runtimeRootWithoutSlash = runtimeRoot.TrimEnd( '/' , '\\' )
2818+ let runtimeRootFacades = Path.Combine( runtimeRootWithoutSlash, " Facades" )
2819+ let runtimeRootWPF = Path.Combine( runtimeRootWithoutSlash, " WPF" )
2820+
2821+ match tcConfig.resolutionEnvironmentwith
2822+ | ResolutionEnvironment.CompilationAndEvaluation->
2823+ // Default compilation-and-execution-time references on .NET Framework and Mono, e.g. for F# Interactive
2824+ //
2825+ // In the current way of doing things, F# Interactive refers to implementation assemblies.
2826+ yield runtimeRoot
2827+ if Directory.Exists( runtimeRootFacades) then
2828+ yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2829+ if Directory.Exists( runtimeRootWPF) then
2830+ yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2831+
2832+ | ResolutionEnvironment.EditingOrCompilation_ ->
2833+ #if ENABLE_ MONO_ SUPPORT
2834+ if runningOnMonothen
2835+ // Default compilation-time references on Mono
2836+ //
2837+ // On Mono, the default references come from the implementation assemblies.
2838+ // This is because we have had trouble reliably using MSBuild APIs to compute DotNetFrameworkReferenceAssembliesRootDirectory on Mono.
2839+ yield runtimeRoot
2840+ if Directory.Exists( runtimeRootFacades) then
2841+ yield runtimeRootFacades// System.Runtime.dll is in /usr/lib/mono/4.5/Facades
2842+ if Directory.Exists( runtimeRootWPF) then
2843+ yield runtimeRootWPF// PresentationCore.dll is in C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF
2844+ // On Mono we also add a default reference to the 4.5-api and 4.5-api/Facades directories.
2845+ let runtimeRootApi = runtimeRootWithoutSlash+ " -api"
2846+ let runtimeRootApiFacades = Path.Combine( runtimeRootApi, " Facades" )
2847+ if Directory.Exists( runtimeRootApi) then
2848+ yield runtimeRootApi
2849+ if Directory.Exists( runtimeRootApiFacades) then
2850+ yield runtimeRootApiFacades
2851+ else
28422852#endif
2843- | _ ->
2853+ // Default compilation-time references on .NET Framework
2854+ //
2855+ // This is the normal case for "fsc.exe a.fs". We refer to the reference assemblies folder.
28442856let frameworkRoot = tcConfig.legacyReferenceResolver.DotNetFrameworkReferenceAssembliesRootDirectory
28452857let frameworkRootVersion = Path.Combine( frameworkRoot, tcConfig.targetFrameworkVersion)
28462858yield frameworkRootVersion
28472859let facades = Path.Combine( frameworkRootVersion, " Facades" )
28482860if Directory.Exists( facades) then
28492861yield facades
28502862]
2851- with e->
2852- errorRecovery e range0; []
2863+ with e->
2864+ errorRecovery e range0; []
28532865
28542866member tcConfig.ComputeLightSyntaxInitialStatus ( filename ) =
28552867use unwindBuildPhase= PushThreadBuildPhaseUntilUnwind BuildPhase.Parameter
@@ -4854,7 +4866,7 @@ type LoadClosure =
48544866
48554867[<RequireQualifiedAccess>]
48564868type CodeContext =
4857- | Evaluation // in fsi.exe
4869+ | CompilationAndEvaluation // in fsi.exe
48584870| Compilation// in fsc.exe
48594871| Editing// in VS
48604872
@@ -4887,7 +4899,7 @@ module private ScriptPreprocessClosure =
48874899// .fsx -- EDITING + !COMPILED\INTERACTIVE
48884900let defines =
48894901match codeContextwith
4890- | CodeContext.Evaluation -> [ " INTERACTIVE" ]
4902+ | CodeContext.CompilationAndEvaluation -> [ " INTERACTIVE" ]
48914903| CodeContext.Compilation-> [ " COMPILED" ]
48924904| CodeContext.Editing-> " EDITING" :: ( if IsScript filenamethen [ " INTERACTIVE" ] else [ " COMPILED" ])
48934905let lexbuf = UnicodeLexing.StringAsLexbuf source
@@ -4898,7 +4910,7 @@ module private ScriptPreprocessClosure =
48984910/// Create a TcConfig for load closure starting from a single .fsx file
48994911let CreateScriptSourceTcConfig ( legacyReferenceResolver , defaultFSharpBinariesDir , filename : string , codeContext , useSimpleResolution , useFsiAuxLib , basicReferences , applyCommandLineArgs , assumeDotNetFramework ) =
49004912let projectDir = Path.GetDirectoryName( filename)
4901- let isInteractive = ( codeContext= CodeContext.Evaluation )
4913+ let isInteractive = ( codeContext= CodeContext.CompilationAndEvaluation )
49024914let isInvalidationSupported = ( codeContext= CodeContext.Editing)
49034915let tcConfigB = TcConfigBuilder.CreateNew( legacyReferenceResolver, defaultFSharpBinariesDir, true (* optimize for memory*) , projectDir, isInteractive, isInvalidationSupported, defaultCopyFSharpCore= false )
49044916 applyCommandLineArgs tcConfigB
@@ -4908,12 +4920,14 @@ module private ScriptPreprocessClosure =
49084920
49094921 tcConfigB.resolutionEnvironment<-
49104922match codeContextwith
4911- | CodeContext.Editing-> ReferenceResolver.DesignTimeLike
4923+ | CodeContext.Editing-> ResolutionEnvironment.EditingOrCompilationtrue
4924+ | CodeContext.Compilation-> ResolutionEnvironment.EditingOrCompilationfalse
4925+ | CodeContext.CompilationAndEvaluation->
49124926#if FSI_ TODO_ NETCORE
4913- // "RuntimeLike " assembly resolution for F# Interactive is not yet properly figured out on .NET Core
4914- | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.CompileTimeLike
4927+ // "CompilationAndEvaluation " assembly resolution for F# Interactive is not yet properly figured out on .NET Core
4928+ ResolutionEnvironment.EditingOrCompilation false
49154929#else
4916- | CodeContext.Compilation | CodeContext.Evaluation -> ReferenceResolver.RuntimeLike
4930+ ResolutionEnvironment.CompilationAndEvaluation
49174931#endif
49184932 tcConfigB.framework<- false
49194933 tcConfigB.useSimpleResolution<- useSimpleResolution