diff --git a/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md b/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md index cc417b8fd81..62ee379dfd0 100644 --- a/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md +++ b/docs/release-notes/.FSharp.Compiler.Service/10.0.300.md @@ -2,6 +2,7 @@ * Fix FS0229 B-stream misalignment when reading metadata from assemblies compiled with LangVersion < 9.0, introduced by [#17706](https://github.com/dotnet/fsharp/pull/17706). ([PR #19260](https://github.com/dotnet/fsharp/pull/19260)) * Fix FS3356 false positive for instance extension members with same name on different types, introduced by [#18821](https://github.com/dotnet/fsharp/pull/18821). ([PR #19260](https://github.com/dotnet/fsharp/pull/19260)) +* F# Scripts: Fix default reference paths resolving when an SDK directory is specified. ([PR #19270](https://github.com/dotnet/fsharp/pull/19270)) ### Added diff --git a/src/Compiler/Driver/FxResolver.fs b/src/Compiler/Driver/FxResolver.fs index f9d39d3ba53..8c3cbd5edcc 100644 --- a/src/Compiler/Driver/FxResolver.fs +++ b/src/Compiler/Driver/FxResolver.fs @@ -256,17 +256,28 @@ type internal FxResolver let getImplementationAssemblyDir () = implementationAssemblyDir.Force() - let getFSharpCoreLibraryName = "FSharp.Core" - - let getFsiLibraryName = "FSharp.Compiler.Interactive.Settings" - - // Use the FSharp.Core that is executing with the compiler as a backup reference - let getFSharpCoreImplementationReference () = - Path.Combine(getFSharpCompilerLocation (), getFSharpCoreLibraryName + ".dll") + let getFSharpLibImplementationReferences useFsiAuxLib = + let getFSharpLibImplementationReference libName = + // Use the FSharp.Core/FSharp.Compiler.Interactive.Settings + // that is executing with the compiler as a backup reference + let getDefaultImplementationReference libName = + Path.Combine(getFSharpCompilerLocation (), libName + ".dll") + + match sdkDirOverride with + | None -> getDefaultImplementationReference libName + | Some sdkDirOverride -> + let libPath = Path.Combine(sdkDirOverride, "FSharp", libName + ".dll") + + if File.Exists(libPath) then + libPath + else + getDefaultImplementationReference libName - // Use the FSharp.Compiler.Interactive.Settings executing with the compiler as a backup reference - let getFsiLibraryImplementationReference () = - Path.Combine(getFSharpCompilerLocation (), getFsiLibraryName + ".dll") + [ + getFSharpLibImplementationReference getFSharpCoreLibraryName + if useFsiAuxLib then + getFSharpLibImplementationReference fsiLibraryName + ] // Use the ValueTuple that is executing with the compiler if it is from System.ValueTuple // or the System.ValueTuple.dll that sits alongside the compiler. (Note we always ship one with the compiler) @@ -615,9 +626,7 @@ type internal FxResolver let roots = [ yield! Directory.GetFiles(implDir, "*.dll") - getFSharpCoreImplementationReference () - if useFsiAuxLib then - getFsiLibraryImplementationReference () + yield! getFSharpLibImplementationReferences useFsiAuxLib ] (getDependenciesOf roots).Values |> Seq.toList @@ -928,9 +937,7 @@ type internal FxResolver let sdkReferences = [ yield! Directory.GetFiles(path, "*.dll") - getFSharpCoreImplementationReference () - if useFsiAuxLib then - getFsiLibraryImplementationReference () + yield! getFSharpLibImplementationReferences useFsiAuxLib ] |> List.filter (Path.GetFileNameWithoutExtension >> (!!) >> systemAssemblies.Contains)