From 8b8da8d020416b80d6f882fefc4a697c8a816a11 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Sun, 29 Nov 2020 20:13:10 -0800 Subject: [PATCH 1/3] Fix net sdk references discovery --- src/fsharp/CompilerConfig.fs | 2 -- src/fsharp/DotNetFrameworkDependencies.fs | 9 +++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/fsharp/CompilerConfig.fs b/src/fsharp/CompilerConfig.fs index b77e0361cdd..4a324ab7097 100644 --- a/src/fsharp/CompilerConfig.fs +++ b/src/fsharp/CompilerConfig.fs @@ -877,8 +877,6 @@ type TcConfig private (data: TcConfigBuilder, validate: bool) = #endif None, data.legacyReferenceResolver.HighestInstalledNetFrameworkVersion() - let systemAssemblies = systemAssemblies - member x.primaryAssembly = data.primaryAssembly member x.noFeedback = data.noFeedback member x.stackReserveSize = data.stackReserveSize diff --git a/src/fsharp/DotNetFrameworkDependencies.fs b/src/fsharp/DotNetFrameworkDependencies.fs index 0fcb0e6d9b8..5eb5c5a9360 100644 --- a/src/fsharp/DotNetFrameworkDependencies.fs +++ b/src/fsharp/DotNetFrameworkDependencies.fs @@ -62,13 +62,18 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies // packs\Microsoft.NETCore.App.Ref\sdk-version\netcoreappn.n // we will rely on the sdk-version match on the two paths to ensure that we get the product that ships with the // version of the runtime we are executing on - // Use the reference assemblies for the highest netcoreapp tfm that we find in that location. + // Use the reference assemblies for the highest netcoreapp tfm that we find in that location that is + // lower than or equal to the implementation version. let version, frameworkRefsPackDirectoryRoot = try let version = DirectoryInfo(implementationAssemblyDir).Name let microsoftNETCoreAppRef = Path.Combine(implementationAssemblyDir, "../../../packs/Microsoft.NETCore.App.Ref") if Directory.Exists(microsoftNETCoreAppRef) then - Some version, Some microsoftNETCoreAppRef + let directory = DirectoryInfo(microsoftNETCoreAppRef).GetDirectories() + |> Array.sortBy (fun di -> di.Name) + |> Array.filter(fun di -> di.Name <= version) + |> Array.last + Some (directory.Name), Some microsoftNETCoreAppRef else Some version, None with | _ -> None, None From e52d828515b23b845fbf062d658866d12a7b0540 Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Mon, 30 Nov 2020 15:20:49 -0800 Subject: [PATCH 2/3] Do numbers properly --- src/fsharp/DotNetFrameworkDependencies.fs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/fsharp/DotNetFrameworkDependencies.fs b/src/fsharp/DotNetFrameworkDependencies.fs index 5eb5c5a9360..6c6675d1835 100644 --- a/src/fsharp/DotNetFrameworkDependencies.fs +++ b/src/fsharp/DotNetFrameworkDependencies.fs @@ -29,7 +29,7 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies location let inline ifEmptyUse alternative filename = if String.IsNullOrWhiteSpace filename then alternative else filename - + let getFSharpCoreLibraryName = "FSharp.Core" let getFsiLibraryName = "FSharp.Compiler.Interactive.Settings" let getDefaultFSharpCoreLocation = Path.Combine(fSharpCompilerLocation, getFSharpCoreLibraryName + ".dll") @@ -64,13 +64,19 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies // version of the runtime we are executing on // Use the reference assemblies for the highest netcoreapp tfm that we find in that location that is // lower than or equal to the implementation version. + let zeroVersion = Version("0.0.0.0") let version, frameworkRefsPackDirectoryRoot = try + let computeVersion version = + match Version.TryParse(version) with + | true, v -> v + | false, _ -> zeroVersion + let version = DirectoryInfo(implementationAssemblyDir).Name let microsoftNETCoreAppRef = Path.Combine(implementationAssemblyDir, "../../../packs/Microsoft.NETCore.App.Ref") if Directory.Exists(microsoftNETCoreAppRef) then let directory = DirectoryInfo(microsoftNETCoreAppRef).GetDirectories() - |> Array.sortBy (fun di -> di.Name) + |> Array.sortBy (fun di -> (computeVersion di.Name)) |> Array.filter(fun di -> di.Name <= version) |> Array.last Some (directory.Name), Some microsoftNETCoreAppRef From 994d06ada7d29e104ff013128c71aedf1ebc72ec Mon Sep 17 00:00:00 2001 From: KevinRansom Date: Mon, 30 Nov 2020 17:33:43 -0800 Subject: [PATCH 3/3] version filter --- src/fsharp/DotNetFrameworkDependencies.fs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/fsharp/DotNetFrameworkDependencies.fs b/src/fsharp/DotNetFrameworkDependencies.fs index 6c6675d1835..1f7055a90ad 100644 --- a/src/fsharp/DotNetFrameworkDependencies.fs +++ b/src/fsharp/DotNetFrameworkDependencies.fs @@ -72,16 +72,17 @@ module internal FSharp.Compiler.DotNetFrameworkDependencies | true, v -> v | false, _ -> zeroVersion - let version = DirectoryInfo(implementationAssemblyDir).Name + let version = computeVersion (DirectoryInfo(implementationAssemblyDir).Name) let microsoftNETCoreAppRef = Path.Combine(implementationAssemblyDir, "../../../packs/Microsoft.NETCore.App.Ref") if Directory.Exists(microsoftNETCoreAppRef) then let directory = DirectoryInfo(microsoftNETCoreAppRef).GetDirectories() - |> Array.sortBy (fun di -> (computeVersion di.Name)) - |> Array.filter(fun di -> di.Name <= version) + |> Array.map (fun di -> computeVersion di.Name) + |> Array.sort + |> Array.filter(fun v -> v <= version) |> Array.last - Some (directory.Name), Some microsoftNETCoreAppRef + Some (directory.ToString()), Some microsoftNETCoreAppRef else - Some version, None + None, None with | _ -> None, None // Tries to figure out the tfm for the compiler instance.