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

update version-finding algorithm to probe packs dir as well as runtime dir #556

Merged
merged 1 commit into from
Feb 19, 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
8 changes: 4 additions & 4 deletions src/ProjectSystem/Environment.fs
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,21 @@ module Environment =

/// because 3.x is the minimum SDK that we support for FSI, we want to float to the latest
/// 3.x sdk that the user has installed, to prevent hard-coding.
let latest3xSdkVersion sdkRoot =
let latest3xSdkVersion dotnetRoot =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed these parameters to reflect their true purpose. SDK root in the current lingo means dotnet-root/sdk, but what was passed in to these functions is the dotnet-root.

let minSDKVersion = FSIRefs.NugetVersion(3,0,100,"")
lazy (
match FSIRefs.sdkVersions sdkRoot with
match FSIRefs.sdkVersions dotnetRoot with
| None -> None
| Some sortedSdkVersions ->
maxVersionWithThreshold minSDKVersion sortedSdkVersions
)

/// because 3.x is the minimum runtime that we support for FSI, we want to float to the latest
/// 3.x runtime that the user has installed, to prevent hard-coding.
let latest3xRuntimeVersion sdkRoot =
let latest3xRuntimeVersion dotnetRoot =
let minRuntimeVersion = FSIRefs.NugetVersion(3,0,0,"")
lazy (
match FSIRefs.runtimeVersions sdkRoot with
match FSIRefs.runtimeVersions dotnetRoot with
| None -> None
| Some sortedRuntimeVersions ->
maxVersionWithThreshold minRuntimeVersion sortedRuntimeVersions
Expand Down
36 changes: 26 additions & 10 deletions src/ProjectSystem/FSIRefs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,46 @@ let versionDirectoriesIn (baseDir: string) =
|> Array.map (Path.GetFileName >> deconstructVersion)
|> Array.sortWith compareNugetVersion

/// path to the directory where .Net SDK versions are stored
let sdkDir dotnetRoot = Path.Combine (dotnetRoot, "sdk")

/// returns a sorted list of the SDK versions available at the given dotnet root
let sdkVersions dotnetRoot =
let sdkDir = Path.Combine (dotnetRoot, "sdk")
let sdkDir = sdkDir dotnetRoot
if Directory.Exists sdkDir
then Some (versionDirectoriesIn sdkDir)
else None

/// returns a sorted list of the .Net Core runtime versions available at the given dotnet root
/// path to the .netcoreapp reference assembly storage location
let netcoreAppPacksDir dotnetRoot = Path.Combine(dotnetRoot, "packs/Microsoft.NETCore.App.Ref")
/// path to the .netcoreapp implementation assembly storage location
let netcoreAppDir dotnetRoot = Path.Combine(dotnetRoot, "shared/Microsoft.NETCore.App")

/// Returns a sorted list of the .Net Core runtime versions available at the given dotnet root.
///
/// If the reference-dll packs directory (`<dotnet root>/packs/Microsoft.NETCore.App.Ref`) is present that is used, otherwise
/// defaults to the actual runtime implementation dlls (`<dotnet root>/shared/Microsoft.NETCore.app`).
let runtimeVersions dotnetRoot =
let runtimesDir = Path.Combine(dotnetRoot, "shared/Microsoft.NETCore.App")
if Directory.Exists runtimesDir
then Some (versionDirectoriesIn runtimesDir)
else None
let runtimesDir = netcoreAppDir dotnetRoot
let packsDir = netcoreAppPacksDir dotnetRoot
if Directory.Exists packsDir
then
Some (versionDirectoriesIn packsDir)
else
if Directory.Exists runtimesDir
then Some (versionDirectoriesIn runtimesDir)
else None

let appPackDir dotnetRoot runtimeVersion tfm =
let packDir = Path.Combine(dotnetRoot, "packs/Microsoft.NETCore.App.Ref", runtimeVersion, "ref", tfm)
let packDir = Path.Combine(netcoreAppPacksDir dotnetRoot, runtimeVersion, "ref", tfm)
if Directory.Exists packDir then Some packDir else None

let compilerDir dotnetRoot sdkVersion =
let compilerDir = Path.Combine(dotnetRoot, "sdk", sdkVersion, "FSharp")
let compilerDir = Path.Combine(sdkDir dotnetRoot, sdkVersion, "FSharp")
if Directory.Exists compilerDir then Some compilerDir else None

let runtimeDir dotnetRoot runtimeVersion =
let runtimeDir = Path.Combine(dotnetRoot, "shared/Microsoft.NETCore.App", runtimeVersion)
let runtimeDir = Path.Combine(netcoreAppDir dotnetRoot, runtimeVersion)
if Directory.Exists runtimeDir then Some runtimeDir else None

/// given the pack directory and the runtime directory, we prefer the pack directory (because these are ref dlls)
Expand Down Expand Up @@ -132,4 +148,4 @@ let tfmForRuntime =
match compareNugetVersion sdkVersion netcore3 with
| 1 | 0 when compareNugetVersion sdkVersion netcore31 = -1 -> "netcoreapp3.0"
| 1 | 0 -> "netcoreapp3.1"
| _ -> "netcoreapp2.2"
| _ -> "netcoreapp2.2"