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

Add another dotnet runtime detector #203

Closed
wants to merge 1 commit into from
Closed
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
19 changes: 19 additions & 0 deletions src/Ionide.ProjInfo/Utils.fs
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,32 @@ module Paths =
else
None

let private tryFindFromSelf () =
let rec findDotnetAbove (self: DirectoryInfo) =
match self.Parent with
| null -> None
| parent ->
let candidate =
Path.Combine(parent.FullName, dotnetBinaryName)
|> FileInfo
|> checkExistence

match candidate with
| Some candidate -> Some candidate
| None -> findDotnetAbove parent

RuntimeEnvironment.GetRuntimeDirectory()
|> DirectoryInfo
|> findDotnetAbove

/// <summary>
/// provides the path to the `dotnet` binary running this library, respecting various dotnet <see href="https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-environment-variables#dotnet_root-dotnet_rootx86%5D">environment variables</see>.
/// Also probes the PATH and checks the default installation locations
/// </summary>
let dotnetRoot =
lazy
(tryFindFromEnvVar ()
|> Option.orElseWith tryFindFromSelf
|> Option.orElseWith tryFindFromPATH
|> Option.orElseWith tryFindFromDefaultDirs)

Expand Down
Loading