Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Finds outdated NuGet references (with Paket)
module OutdatedPackages
#r "../../../packages/FAKE/tools/FakeLib.dll"
open System
open Fake
let timeout = TimeSpan.FromMinutes 5.
let parseOutput (lines: string seq) =
lines
|> Seq.fold (fun state line ->
match state, line.Trim() with
| (false, list), "Outdated packages found:" -> true, list
| (true, list), "Performance:" -> false, list
| (true, list), line when line.StartsWith "* " -> true, line :: list
| state, _ -> state) (false, [])
|> snd
|> List.rev
let filterByPrefix prefix (msg: string) =
if msg.StartsWith("* " + prefix) then true else trace msg; false
let runPaket () =
ProcessHelper.ExecProcessAndReturnMessages
(fun psi ->
psi.FileName <- ".paket/paket.exe"
psi.Arguments <- "outdated")
timeout
|> fun r -> r.Messages
let target packagePrefix =
runPaket ()
|> parseOutput
|> List.filter (filterByPrefix packagePrefix)
|> function [] -> () | any -> failwithf "Outdated packages found: %A" any
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment