Compare commits

...

1 Commits

Author SHA1 Message Date
Patrick Stevens
4ab66204c4 Cope with multiple TargetFrameworks (#46) 2024-06-09 10:03:48 +01:00
4 changed files with 49 additions and 14 deletions

View File

@@ -54,23 +54,57 @@ module Program =
|> Option.defaultValue RollForward.Minor |> Option.defaultValue RollForward.Minor
| s -> RollForward.Parse s | s -> RollForward.Parse s
let desired = Version config.Framework.Version let desiredVersions =
match config.Framework with
| Some f -> [ Version f.Version, f.Name ]
| None ->
match config.Frameworks with
| Some f -> f |> List.map (fun f -> Version f.Version, f.Name)
| None ->
failwith
"Could not deduce a framework version due to lack of either Framework or Frameworks in runtimeconfig"
let compatiblyNamedRuntimes =
f.Frameworks
|> Seq.collect (fun availableFramework ->
desiredVersions
|> List.choose (fun (desiredVersion, desiredName) ->
if desiredName = availableFramework.Name then
Some
{|
Desired = desiredVersion
Name = desiredName
Installed = availableFramework
InstalledVersion = Version availableFramework.Version
|}
else
None
)
)
|> Seq.toList
match rollForward with match rollForward with
| RollForward.Minor -> | RollForward.Minor ->
let available = let available =
f.Frameworks compatiblyNamedRuntimes
|> Seq.choose (fun fi -> |> Seq.filter (fun data ->
if fi.Name = config.Framework.Name then data.InstalledVersion.Major = data.Desired.Major
Some (fi, Version fi.Version) && data.InstalledVersion.Minor >= data.Desired.Minor
else
None
) )
|> Seq.filter (fun (_, version) -> version.Major = desired.Major && version.Minor >= desired.Minor) |> Seq.groupBy (fun data -> data.Name)
|> Seq.tryMinBy (fun (_, version) -> version.Minor, version.Build) |> Seq.map (fun (name, data) ->
let data =
data
|> Seq.minBy (fun data -> data.InstalledVersion.Minor, data.InstalledVersion.Build)
name, data.Installed
)
// TODO: how do we select between many available frameworks?
|> Seq.tryHead
match available with match available with
| Some (f, _) -> Some (Choice1Of2 f) | Some (_, f) -> Some (Choice1Of2 f)
| None -> | None ->
// TODO: maybe we can ask the SDK. But we keep on trucking: maybe we're self-contained, // TODO: maybe we can ask the SDK. But we keep on trucking: maybe we're self-contained,
// and we'll actually find all the runtime next to the DLL. // and we'll actually find all the runtime next to the DLL.

View File

@@ -14,7 +14,8 @@ type FrameworkDescription =
type RuntimeOptions = type RuntimeOptions =
{ {
Tfm : string Tfm : string
Framework : FrameworkDescription Framework : FrameworkDescription option
Frameworks : FrameworkDescription list option
RollForward : string option RollForward : string option
} }

View File

@@ -39,7 +39,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Spectre.Console" Version="0.49.1" /> <PackageReference Include="Spectre.Console" Version="0.49.1" />
<PackageReference Include="WoofWare.DotnetRuntimeLocator" Version="0.1.2" /> <PackageReference Include="WoofWare.DotnetRuntimeLocator" Version="0.1.3" />
<PackageReference Include="WoofWare.Myriad.Plugins.Attributes" Version="3.1.4" /> <PackageReference Include="WoofWare.Myriad.Plugins.Attributes" Version="3.1.4" />
<PackageReference Include="Myriad.SDK" Version="0.8.3" /> <PackageReference Include="Myriad.SDK" Version="0.8.3" />
<PackageReference Include="WoofWare.Myriad.Plugins" Version="$(WoofWareMyriadPluginVersion)" PrivateAssets="all" /> <PackageReference Include="WoofWare.Myriad.Plugins" Version="$(WoofWareMyriadPluginVersion)" PrivateAssets="all" />

View File

@@ -183,8 +183,8 @@
}) })
(fetchNuGet { (fetchNuGet {
pname = "WoofWare.DotnetRuntimeLocator"; pname = "WoofWare.DotnetRuntimeLocator";
version = "0.1.2"; version = "0.1.3";
sha256 = "0kwkq28ddzc0bpr22jmgcl8dhnhg776gf6l054rsxw8lrvpwhmv9"; sha256 = "0qw41mcvx4qy012pj1dlpdfwsz036qrx7xnzsirk5fz715f1a45m";
}) })
(fetchNuGet { (fetchNuGet {
pname = "WoofWare.Myriad.Plugins"; pname = "WoofWare.Myriad.Plugins";