Compare commits

...

1 Commits

Author SHA1 Message Date
Patrick Stevens
3d04199c56 More runtimes (#81) 2024-06-16 16:13:58 +01:00

View File

@@ -7,11 +7,7 @@ open WoofWare.DotnetRuntimeLocator
/// Functions for locating .NET runtimes. /// Functions for locating .NET runtimes.
[<RequireQualifiedAccess>] [<RequireQualifiedAccess>]
module DotnetRuntime = module DotnetRuntime =
let private selectRuntime let private selectRuntime (config : RuntimeOptions) (f : DotnetEnvironmentInfo) : DirectoryInfo list =
(config : RuntimeOptions)
(f : DotnetEnvironmentInfo)
: Choice<DotnetEnvironmentFrameworkInfo, DotnetEnvironmentSdkInfo> option
=
let rollForward = let rollForward =
match Environment.GetEnvironmentVariable "DOTNET_ROLL_FORWARD" with match Environment.GetEnvironmentVariable "DOTNET_ROLL_FORWARD" with
| null -> | null ->
@@ -66,15 +62,13 @@ module DotnetRuntime =
name, data.Installed name, data.Installed
) )
// TODO: how do we select between many available frameworks? |> Seq.toList
|> Seq.tryHead
match available with // TODO: maybe we can ask the SDK if we don't have any runtimes.
| Some (_, f) -> Some (Choice1Of2 f) // But we keep on trucking: maybe we're self-contained, and we'll actually find all the runtime next to the
| None -> // DLL.
// TODO: maybe we can ask the SDK. But we keep on trucking: maybe we're self-contained, available
// and we'll actually find all the runtime next to the DLL. |> List.map (fun (_name, runtime) -> DirectoryInfo $"%s{runtime.Path}/%s{runtime.Version}")
None
| _ -> failwith "non-minor RollForward not supported yet; please shout if you want it" | _ -> failwith "non-minor RollForward not supported yet; please shout if you want it"
/// Given an executable DLL, locate the .NET runtime that can best run it. /// Given an executable DLL, locate the .NET runtime that can best run it.
@@ -96,9 +90,4 @@ module DotnetRuntime =
let runtime = selectRuntime runtimeConfig availableRuntimes let runtime = selectRuntime runtimeConfig availableRuntimes
match runtime with dll.Directory :: runtime
| None ->
// Keep on trucking: let's be optimistic and hope that we're self-contained.
[ dll.Directory ]
| Some (Choice1Of2 runtime) -> [ dll.Directory ; DirectoryInfo $"%s{runtime.Path}/%s{runtime.Version}" ]
| Some (Choice2Of2 sdk) -> [ dll.Directory ; DirectoryInfo sdk.Path ]