Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save denmerc/adeacd01efa38c01e37e9007b2b43bd8 to your computer and use it in GitHub Desktop.
Save denmerc/adeacd01efa38c01e37e9007b2b43bd8 to your computer and use it in GitHub Desktop.
A must have for your script file to ease spreading a small proof of concept with dependencies!
open System
open System.IO
open System.Diagnostics
let downloadDependencies deps =
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
if not (File.Exists "paket.exe") then
async {
let url = "http://fsprojects.github.io/Paket/stable"
use wc = new Net.WebClient()
wc.DownloadProgressChanged.Add(fun a -> printfn "Progress downloading paket.exe: %d" a.ProgressPercentage)
let tmp = Path.GetTempFileName()
let stable = wc.DownloadString(url)
do! wc.AsyncDownloadFile(stable |> Uri, tmp)
File.Move(tmp,Path.GetFileName stable)
} |> Async.RunSynchronously
printfn "Finished downloading paket.exe!"
let invokePaket args =
use process =
new Process(
StartInfo =
new ProcessStartInfo(
FileName = "./paket.exe",
Arguments = args,
UseShellExecute = false))
process.Start() |> ignore
process.WaitForExit()
if not (File.Exists "paket.dependencies") && not (File.Exists "paket.lock") then
invokePaket "init"
for dep in deps do
sprintf "add %s" dep
|> invokePaket
downloadDependencies [ "MathNet.Numerics"; "MathNet.Numerics.FSharp"] // Append the package names to this list!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment