Skip to content

Instantly share code, notes, and snippets.

@jkone27
Created March 2, 2024 22:40
Show Gist options
  • Save jkone27/3752f33a7b365e98ec2fb45d63549e7a to your computer and use it in GitHub Desktop.
Save jkone27/3752f33a7b365e98ec2fb45d63549e7a to your computer and use it in GitHub Desktop.
Copy dlls to libraries directory for SQLProvider
#r "nuget: Fli"
open Fli
// change these or pass as arguments (modify script)
[<Literal>]
let packagesFolder = "$HOME/.nuget/packages"
[<Literal>]
let destFolder = __SOURCE_DIRECTORY__ + "/libraries"
[<Literal>]
let netVersion = "net8.0"
let dynamicLibs =
[ "Npgsql,8.0.0"
"System.Text.Json,8.0.0"
"System.Threading.Channels,8.0.0"
"Microsoft.Bcl.AsyncInterfaces,8.0.0"
"Microsoft.Extensions.Logging.Abstractions,8.0.0"
"System.Memory.Data,8.0.0"
"System.Diagnostics.DiagnosticSource,8.0.0" ]
let find packageName version =
$"""
find "{packagesFolder}" -type f -name "{packageName}.dll" -path "*/{version}/lib/{netVersion}/*"
"""
let copy src = $"cp {src} {destFolder}"
let processOneAsync dll v =
async {
printfn $"processing {(dll, v)}"
let str = find dll v
//printfn $"CMD: {str}"
let! findResult =
cli {
Shell Shells.BASH
Command str
CancelAfter 20000
}
|> Command.executeAsync
match (findResult.Error, findResult.ExitCode) with
| Some(err), code -> printfn $"NOT FOUND: {(dll, v)}, {err}. {code}"
| _ -> printfn $"found!"
match findResult.Text with
| Some(path) ->
let! cpResult =
let str = copy path
cli {
Shell Shells.BASH
Command str
CancelAfter 20000
}
|> Command.executeAsync
match (findResult.Error, findResult.ExitCode) with
| Some(err), code -> printfn $"COPY ERROR: {(dll, v)}, {err}. {code}"
| _ -> printfn $"file {(dll, v)} copied to {destFolder}."
| None -> ()
}
let toProcess =
dynamicLibs
|> Seq.map (fun x ->
let r = x.Split(",")
r[0], r[1])
let sequentialProcess () =
for (dll, v) in toProcess do
processOneAsync dll v |> Async.RunSynchronously
// let parallelProcess () =
// toProcess
// |> Seq.map (fun (dll, v) -> processOneAsync dll v)
// |> Async.Parallel
// |> Async.RunSynchronously
sequentialProcess ()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment