f# - FAKE: Get all projects referenced by a solution file -
how hold of projects referenced solution file?
here have concrete use case. have stolen target copybinaries projectscaffold. copies output of project builds separate folder. not choosy , copies output of every project finds.
target "copybinaries" (fun _ -> !! "src/**/*.??proj" -- "src/**/*.shproj" |> seq.map (fun f -> ((system.io.path.getdirectoryname f) </> "bin/release", bindir </> (system.io.path.getfilenamewithoutextension f))) |> seq.iter (fun (fromdir, todir) -> copydir todir fromdir (fun _ -> true)) )
what if want copy output of projects referenced explicitly in solution file. think of this:
target "copybinaries" (fun _ -> !! solutionfile |> getprojectfiles |> seq.map (fun f -> ((system.io.path.getdirectoryname f) </> "bin/release", bindir </> (system.io.path.getfilenamewithoutextension f))) |> seq.iter (fun (fromdir, todir) -> copydir todir fromdir (fun _ -> true)) )
the function getprojectfiles takes solution file , extracts referenced project files.
is there hypothetical function in fake available?
there nothing have found gives kind of information solution files out of box. small number of functions, alternative possible:
let root = directoryinfo "." let solutionreferences basedir = basedir |> filesindirmatching "*.sln" |> seq.ofarray let solutionnames paths = paths |> seq.map (fun (f:system.io.fileinfo) -> f.fullname) let projectsinsolution solutions = solutions |> seq.collect readfile |> seq.filter (fun line -> line.startswith("project")) let projectnames projects = projects |> seq.map (fun (line:string) -> (line.split [|','|]).[1]) target "sln" ( fun () -> root |> solutionreferences |> solutionnames |> projectsinsolution |> projectnames |> seq.iter (printfn "%s"))
this can consolidated , functions skipped grouping like. may have found out or else, knows there options. thank you. day.
Comments
Post a Comment