Created
October 19, 2010 19:32
-
-
Save rojepp/634908 to your computer and use it in GitHub Desktop.
Love the elegance of F#. This code looks for the TFS Command line tool and returns Some(path) or None
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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