mirror of
https://github.com/Smaug123/WoofWare.Whippet
synced 2025-10-05 15:58:39 +00:00
Bump deps (#35)
Some checks failed
.NET / build (Debug) (push) Has been cancelled
.NET / build (Release) (push) Has been cancelled
.NET / analyzers (push) Has been cancelled
.NET / check-dotnet-format (push) Has been cancelled
.NET / check-nix-format (push) Has been cancelled
.NET / Check links (push) Has been cancelled
.NET / Check flake (push) Has been cancelled
.NET / nuget-pack (push) Has been cancelled
.NET / check-accurate-generations (push) Has been cancelled
.NET / expected-pack (push) Has been cancelled
.NET / all-required-checks-complete (push) Has been cancelled
.NET / nuget-publish (push) Has been cancelled
.NET / nuget-publish-core (push) Has been cancelled
.NET / nuget-publish-fantomas (push) Has been cancelled
.NET / nuget-publish-json-plugin (push) Has been cancelled
.NET / nuget-publish-json-attrs (push) Has been cancelled
.NET / nuget-publish-argparser-plugin (push) Has been cancelled
.NET / nuget-publish-argparser-attrs (push) Has been cancelled
.NET / nuget-publish-httpclient-plugin (push) Has been cancelled
.NET / nuget-publish-httpclient-attrs (push) Has been cancelled
.NET / nuget-publish-interfacemock-plugin (push) Has been cancelled
.NET / nuget-publish-interfacemock-attrs (push) Has been cancelled
.NET / nuget-publish-swagger-plugin (push) Has been cancelled
Some checks failed
.NET / build (Debug) (push) Has been cancelled
.NET / build (Release) (push) Has been cancelled
.NET / analyzers (push) Has been cancelled
.NET / check-dotnet-format (push) Has been cancelled
.NET / check-nix-format (push) Has been cancelled
.NET / Check links (push) Has been cancelled
.NET / Check flake (push) Has been cancelled
.NET / nuget-pack (push) Has been cancelled
.NET / check-accurate-generations (push) Has been cancelled
.NET / expected-pack (push) Has been cancelled
.NET / all-required-checks-complete (push) Has been cancelled
.NET / nuget-publish (push) Has been cancelled
.NET / nuget-publish-core (push) Has been cancelled
.NET / nuget-publish-fantomas (push) Has been cancelled
.NET / nuget-publish-json-plugin (push) Has been cancelled
.NET / nuget-publish-json-attrs (push) Has been cancelled
.NET / nuget-publish-argparser-plugin (push) Has been cancelled
.NET / nuget-publish-argparser-attrs (push) Has been cancelled
.NET / nuget-publish-httpclient-plugin (push) Has been cancelled
.NET / nuget-publish-httpclient-attrs (push) Has been cancelled
.NET / nuget-publish-interfacemock-plugin (push) Has been cancelled
.NET / nuget-publish-interfacemock-attrs (push) Has been cancelled
.NET / nuget-publish-swagger-plugin (push) Has been cancelled
This commit is contained in:
@@ -6,6 +6,7 @@ open System.Reflection
|
||||
open Ionide.ProjInfo
|
||||
open Ionide.ProjInfo.Types
|
||||
|
||||
open WoofWare.DotnetRuntimeLocator
|
||||
open WoofWare.Whippet.Core
|
||||
|
||||
type Args =
|
||||
@@ -156,7 +157,10 @@ module Program =
|
||||
)
|
||||
|
||||
let runtime =
|
||||
DotnetRuntime.locate (Assembly.GetExecutingAssembly().Location |> FileInfo)
|
||||
Assembly.GetExecutingAssembly().Location
|
||||
|> DotnetRuntime.SelectForDll
|
||||
|> Seq.map DirectoryInfo
|
||||
|> Seq.toList
|
||||
|
||||
let plugins =
|
||||
args.Plugins
|
||||
|
@@ -1,47 +0,0 @@
|
||||
namespace WoofWare.Whippet
|
||||
|
||||
open System
|
||||
|
||||
type FrameworkDescription =
|
||||
{
|
||||
Name : string
|
||||
Version : string
|
||||
}
|
||||
|
||||
type RuntimeOptions =
|
||||
{
|
||||
Tfm : string
|
||||
Framework : FrameworkDescription option
|
||||
Frameworks : FrameworkDescription list option
|
||||
RollForward : string option
|
||||
}
|
||||
|
||||
type RuntimeConfig =
|
||||
{
|
||||
RuntimeOptions : RuntimeOptions
|
||||
}
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
type RollForward =
|
||||
| Minor
|
||||
| Major
|
||||
| LatestPatch
|
||||
| LatestMinor
|
||||
| LatestMajor
|
||||
| Disable
|
||||
|
||||
static member Parse (s : string) : RollForward =
|
||||
if s.Equals ("minor", StringComparison.OrdinalIgnoreCase) then
|
||||
RollForward.Minor
|
||||
elif s.Equals ("major", StringComparison.OrdinalIgnoreCase) then
|
||||
RollForward.Major
|
||||
elif s.Equals ("latestpatch", StringComparison.OrdinalIgnoreCase) then
|
||||
RollForward.LatestPatch
|
||||
elif s.Equals ("latestminor", StringComparison.OrdinalIgnoreCase) then
|
||||
RollForward.LatestMinor
|
||||
elif s.Equals ("latestmajor", StringComparison.OrdinalIgnoreCase) then
|
||||
RollForward.LatestMajor
|
||||
elif s.Equals ("disable", StringComparison.OrdinalIgnoreCase) then
|
||||
RollForward.Disable
|
||||
else
|
||||
failwith $"Could not interpret '%s{s}' as a RollForward"
|
@@ -1,103 +0,0 @@
|
||||
namespace WoofWare.Whippet
|
||||
|
||||
(* File originally generated by Myriad. *)
|
||||
|
||||
/// Module containing JSON parsing methods for the FrameworkDescription type
|
||||
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
|
||||
module FrameworkDescription =
|
||||
/// Parse from a JSON node.
|
||||
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : FrameworkDescription =
|
||||
let arg_1 =
|
||||
(match node.["version"] with
|
||||
| null ->
|
||||
raise (
|
||||
System.Collections.Generic.KeyNotFoundException (
|
||||
sprintf "Required key '%s' not found on JSON object" ("version")
|
||||
)
|
||||
)
|
||||
| v -> v)
|
||||
.AsValue()
|
||||
.GetValue<System.String> ()
|
||||
|
||||
let arg_0 =
|
||||
(match node.["name"] with
|
||||
| null ->
|
||||
raise (
|
||||
System.Collections.Generic.KeyNotFoundException (
|
||||
sprintf "Required key '%s' not found on JSON object" ("name")
|
||||
)
|
||||
)
|
||||
| v -> v)
|
||||
.AsValue()
|
||||
.GetValue<System.String> ()
|
||||
|
||||
{
|
||||
Name = arg_0
|
||||
Version = arg_1
|
||||
}
|
||||
namespace WoofWare.Whippet
|
||||
|
||||
/// Module containing JSON parsing methods for the RuntimeOptions type
|
||||
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
|
||||
module RuntimeOptions =
|
||||
/// Parse from a JSON node.
|
||||
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : RuntimeOptions =
|
||||
let arg_3 =
|
||||
match node.["rollForward"] with
|
||||
| null -> None
|
||||
| v -> v.AsValue().GetValue<System.String> () |> Some
|
||||
|
||||
let arg_2 =
|
||||
match node.["frameworks"] with
|
||||
| null -> None
|
||||
| v ->
|
||||
v.AsArray ()
|
||||
|> Seq.map (fun elt -> FrameworkDescription.jsonParse elt)
|
||||
|> List.ofSeq
|
||||
|> Some
|
||||
|
||||
let arg_1 =
|
||||
match node.["framework"] with
|
||||
| null -> None
|
||||
| v -> FrameworkDescription.jsonParse v |> Some
|
||||
|
||||
let arg_0 =
|
||||
(match node.["tfm"] with
|
||||
| null ->
|
||||
raise (
|
||||
System.Collections.Generic.KeyNotFoundException (
|
||||
sprintf "Required key '%s' not found on JSON object" ("tfm")
|
||||
)
|
||||
)
|
||||
| v -> v)
|
||||
.AsValue()
|
||||
.GetValue<System.String> ()
|
||||
|
||||
{
|
||||
Tfm = arg_0
|
||||
Framework = arg_1
|
||||
Frameworks = arg_2
|
||||
RollForward = arg_3
|
||||
}
|
||||
namespace WoofWare.Whippet
|
||||
|
||||
/// Module containing JSON parsing methods for the RuntimeConfig type
|
||||
[<RequireQualifiedAccess ; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
|
||||
module RuntimeConfig =
|
||||
/// Parse from a JSON node.
|
||||
let jsonParse (node : System.Text.Json.Nodes.JsonNode) : RuntimeConfig =
|
||||
let arg_0 =
|
||||
RuntimeOptions.jsonParse (
|
||||
match node.["runtimeOptions"] with
|
||||
| null ->
|
||||
raise (
|
||||
System.Collections.Generic.KeyNotFoundException (
|
||||
sprintf "Required key '%s' not found on JSON object" ("runtimeOptions")
|
||||
)
|
||||
)
|
||||
| v -> v
|
||||
)
|
||||
|
||||
{
|
||||
RuntimeOptions = arg_0
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
namespace WoofWare.Whippet
|
||||
|
||||
open System
|
||||
open System.IO
|
||||
open WoofWare.DotnetRuntimeLocator
|
||||
|
||||
/// Functions for locating .NET runtimes.
|
||||
[<RequireQualifiedAccess>]
|
||||
module DotnetRuntime =
|
||||
let private selectRuntime
|
||||
(config : RuntimeOptions)
|
||||
(f : DotnetEnvironmentInfo)
|
||||
: Choice<DotnetEnvironmentFrameworkInfo, DotnetEnvironmentSdkInfo> option
|
||||
=
|
||||
let rollForward =
|
||||
match Environment.GetEnvironmentVariable "DOTNET_ROLL_FORWARD" with
|
||||
| null ->
|
||||
config.RollForward
|
||||
|> Option.map RollForward.Parse
|
||||
|> Option.defaultValue RollForward.Minor
|
||||
| s -> RollForward.Parse s
|
||||
|
||||
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
|
||||
| RollForward.Minor ->
|
||||
let available =
|
||||
compatiblyNamedRuntimes
|
||||
|> Seq.filter (fun data ->
|
||||
data.InstalledVersion.Major = data.Desired.Major
|
||||
&& data.InstalledVersion.Minor >= data.Desired.Minor
|
||||
)
|
||||
|> Seq.groupBy (fun data -> data.Name)
|
||||
|> 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
|
||||
| Some (_, f) -> Some (Choice1Of2 f)
|
||||
| None ->
|
||||
// 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.
|
||||
None
|
||||
| _ -> 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.
|
||||
let locate (dll : FileInfo) : DirectoryInfo list =
|
||||
let runtimeConfig =
|
||||
let name =
|
||||
if not (dll.Name.EndsWith (".dll", StringComparison.OrdinalIgnoreCase)) then
|
||||
failwith $"Expected DLL %s{dll.FullName} to end in .dll"
|
||||
|
||||
dll.Name.Substring (0, dll.Name.Length - 4)
|
||||
|
||||
Path.Combine (dll.Directory.FullName, $"%s{name}.runtimeconfig.json")
|
||||
|> File.ReadAllText
|
||||
|> System.Text.Json.Nodes.JsonNode.Parse
|
||||
|> RuntimeConfig.jsonParse
|
||||
|> fun f -> f.RuntimeOptions
|
||||
|
||||
let availableRuntimes = DotnetEnvironmentInfo.Get ()
|
||||
|
||||
let runtime = selectRuntime runtimeConfig availableRuntimes
|
||||
|
||||
match runtime with
|
||||
| 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 ]
|
@@ -4,21 +4,19 @@
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<RollForward>LatestMajor</RollForward>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="RuntimeConfig.fs" />
|
||||
<Compile Include="RuntimeConfigGen.fs" />
|
||||
<Compile Include="AppContext.fs" />
|
||||
<Compile Include="RuntimeLocator.fs" />
|
||||
<Compile Include="Context.fs" />
|
||||
<Compile Include="Program.fs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="WoofWare.DotnetRuntimeLocator" Version="0.1.9" />
|
||||
<PackageReference Include="Ionide.ProjInfo" Version="0.67.0" PrivateAssets="compile" />
|
||||
<PackageReference Include="Microsoft.Build.Framework" Version="17.2.0" ExcludeAssets="runtime" PrivateAssets="all" />
|
||||
<PackageReference Include="NuGet.Frameworks" Version="6.11.1" ExcludeAssets="runtime" PrivateAssets="all" />
|
||||
<PackageReference Include="WoofWare.DotnetRuntimeLocator" Version="0.4.1" />
|
||||
<PackageReference Include="Ionide.ProjInfo" Version="0.71.2" PrivateAssets="compile" />
|
||||
<PackageReference Include="Microsoft.Build.Framework" Version="17.14.8" ExcludeAssets="runtime" PrivateAssets="all" />
|
||||
<PackageReference Include="NuGet.Frameworks" Version="6.14.0" ExcludeAssets="runtime" PrivateAssets="all" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WoofWare.Whippet.Core\WoofWare.Whippet.Core.fsproj" />
|
||||
|
Reference in New Issue
Block a user