Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix net sdk references discovery #10569

Merged
merged 3 commits into from
Dec 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/fsharp/CompilerConfig.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 17 additions & 5 deletions src/fsharp/DotNetFrameworkDependencies.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -62,15 +62,27 @@ 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 zeroVersion = Version("0.0.0.0")
let version, frameworkRefsPackDirectoryRoot =
try
let version = DirectoryInfo(implementationAssemblyDir).Name
let computeVersion version =
match Version.TryParse(version) with
| true, v -> v
| false, _ -> zeroVersion

let version = computeVersion (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.map (fun di -> computeVersion di.Name)
|> Array.sort
|> Array.filter(fun v -> v <= version)
|> Array.last
Some (directory.ToString()), Some microsoftNETCoreAppRef
else
Some version, None
None, None
with | _ -> None, None

// Tries to figure out the tfm for the compiler instance.
Expand Down