Reputation: 2548
Would like to speed up builds using FAKE. Theoretically if I could run a build sequence in parallel (within a target) that should make it faster.
let buildProject outputDir buildTargets projectName =
let setParams p =
{ p with
Verbosity = Some(Quiet)
Targets = buildTargets
Properties =
[ "DevEnvDir", "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools"
"OutputPath", outputDir
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", buildMode ]
}
build setParams projectName |> DoNothing
Target "BuildLibs" (fun _ ->
!! "**/*.csproj"
-- "**/*.Tests.csproj"
//A way to run in parallel??
|> Seq.iter (buildProject buildOutDir ["ReBuild"])
)
Is there a way to run the sequence iteration in parallel?
Upvotes: 1
Views: 327
Reputation: 2548
The easiest option would be:
Target "BuildLibs" (fun _ ->
!! "**/*.csproj"
-- "**/*.Tests.csproj"
|> Seq.ToArray
|> Array.Parallel.iter (buildProject buildOutDir ["ReBuild"])
)
Another alternative is "F# Parallel Sequences" component.
#r "./PATHTOLIB/lib/net40/FSharp.Collections.ParallelSeq.dll"
open FSharp.Collections.ParallelSeq
Target "BuildLibs" (fun _ ->
!! "**/*.csproj"
-- "**/*.Tests.csproj"
|> PSeq.iter (buildProject buildOutDir ["ReBuild"])
)
Upvotes: 1