Skip to content

Instantly share code, notes, and snippets.

@rojepp rojepp/FindTF
Created Oct 19, 2010

What would you like to do?
Love the elegance of F#. This code looks for the TFS Command line tool and returns Some(path) or None
let findtfpath =
let INSTALLDIR = "InstallDir";
let TF_EXE = "TF.exe";
let check value = match box value with
| null -> None
| _ -> Some(value)
|> Seq.choose (fun p -> check(Registry.LocalMachine.OpenSubKey(p)))
|> Seq.choose (fun k -> check(k.GetValue(INSTALLDIR, null) :?> string))
|> (fun p -> System.IO.Path.Combine(p, TF_EXE))
|> Seq.filter System.IO.File.Exists
|> Seq.tryFind(fun f -> true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.