Skip to content

Instantly share code, notes, and snippets.

@rojepp rojepp/FindTF
Created Oct 19, 2010

Embed
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 VS_REGPATHS = [
@"Software\Wow6432Node\Microsoft\VisualStudio\10.0";
@"Software\Microsoft\VisualStudio\10.0";
@"Software\Wow6432Node\Microsoft\VisualStudio\9.0";
@"Software\Microsoft\VisualStudio\9.0";
@"Software\Wow6432Node\Microsoft\VisualStudio\8.0";
@"Software\Microsoft\VisualStudio\8.0"
]
let INSTALLDIR = "InstallDir";
let TF_EXE = "TF.exe";
let check value = match box value with
| null -> None
| _ -> Some(value)
VS_REGPATHS
|> Seq.choose (fun p -> check(Registry.LocalMachine.OpenSubKey(p)))
|> Seq.choose (fun k -> check(k.GetValue(INSTALLDIR, null) :?> string))
|> Seq.map (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.