Last active
July 4, 2019 22:02
-
-
Save devjev/7eb30a887f7ddd9630fccd2a0f47677b to your computer and use it in GitHub Desktop.
Fake build script which copies the build results to a build/* folder
This file contains 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
#load ".fake/build.fsx/intellisense.fsx" | |
open Fake.Core | |
open Fake.DotNet | |
open Fake.IO | |
open Fake.IO.Globbing.Operators | |
open Fake.IO.FileSystemOperators | |
open Fake.Core.TargetOperators | |
// Params ===================================================================== | |
let BINOUT = "build" </> "bin" | |
let NUGOUT = "build" </> "nuget" | |
// Utils ====================================================================== | |
let splitStringBy (sep : string) (text : string) = | |
let sarr = sep.ToCharArray () | |
List.ofArray (text.Split (sarr, System.StringSplitOptions.None)) | |
let makeOutputPaths outputRoot (globbingPattern : IGlobbingPattern) = | |
seq { | |
for path in globbingPattern -> | |
let output = path | |
|> Path.shortenCurrentDirectory | |
|> splitStringBy Path.directorySeparator | |
|> List.filter (fun s -> | |
(s <> "src" && s <> "bin" && s <> ".")) | |
|> List.fold ( @@ ) outputRoot | |
|> Path.getFullName | |
(path, output) | |
} | |
// Targets ==================================================================== | |
Target.create "Clean" (fun _ -> | |
!! "src/**/bin" | |
++ "src/**/obj" | |
++ (BINOUT </> "**") | |
++ (NUGOUT </> "**") | |
|> Shell.cleanDirs | |
) | |
Target.create "Build" (fun _ -> | |
!! "src/**/*.*proj" | |
|> Seq.iter (DotNet.build id) | |
) | |
Target.create "CollateBin" (fun _ -> | |
!! "src/**/bin/**/*" | |
|> makeOutputPaths BINOUT | |
|> Seq.iter ( | |
fun (source, target) -> | |
let dir = Path.getDirectory target | |
Shell.mkdir dir | |
Shell.copyFile target source) | |
) | |
Target.create "All" ignore | |
"Clean" ==> "Build" | |
"Build" ==> "CollateBin" | |
"CollateBin" ==> "All" | |
Target.runOrDefault "All" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment