Skip to content

Instantly share code, notes, and snippets.

@orient-man
Last active September 5, 2017 13:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save orient-man/c29c299ed970fd097f80124ffde734ce to your computer and use it in GitHub Desktop.
Save orient-man/c29c299ed970fd097f80124ffde734ce to your computer and use it in GitHub Desktop.
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