1+ #r " paket:
2+ nuget BlackFox.Fake.BuildTask
3+ nuget Fake.Core.Target
4+ nuget Fake.Core.Process
5+ nuget Fake.Core.ReleaseNotes
6+ nuget Fake.IO.FileSystem
7+ nuget Fake.DotNet.Cli
8+ nuget Fake.DotNet.MSBuild
9+ nuget Fake.DotNet.AssemblyInfoFile
10+ nuget Fake.DotNet.Paket
11+ nuget Fake.DotNet.FSFormatting
12+ nuget Fake.DotNet.Fsi
13+ nuget Fake.DotNet.NuGet
14+ nuget Fake.Api.Github
15+ nuget Fake.DotNet.Testing.Expecto
16+ nuget Fake.Tools.Git //"
17+
18+ #if ! FAKE
19+ #load " ./.fake/build.fsx/intellisense.fsx"
20+ #r " netstandard" // Temp fix for https://github.com/dotnet/fsharp/issues/5216
21+ #endif
22+
23+ open BlackFox.Fake
24+ open System.IO
25+ open Fake.Core
26+ open Fake.DotNet
27+ open Fake.IO
28+ open Fake.IO .FileSystemOperators
29+ open Fake.IO .Globbing .Operators
30+ open Fake.Tools
31+
32+ [<AutoOpen>]
33+ /// user interaction prompts for critical build tasks where you may want to interrupt when you see wrong inputs.
34+ module MessagePrompts =
35+
36+ let prompt ( msg : string ) =
37+ System.Console.Write( msg)
38+ System.Console.ReadLine() .Trim()
39+ |> function | " " -> None | s -> Some s
40+ |> Option.map ( fun s -> s.Replace ( " \" " , " \\\" " ))
41+
42+ let rec promptYesNo msg =
43+ match prompt ( sprintf " %s [Yn]: " msg) with
44+ | Some " Y" | Some " y" -> true
45+ | Some " N" | Some " n" -> false
46+ | _ -> System.Console.WriteLine( " Sorry, invalid answer" ); promptYesNo msg
47+
48+ let releaseMsg = """ This will stage all uncommitted changes, push them to the origin and bump the release version to the latest number in the RELEASE_NOTES.md file.
49+ Do you want to continue?"""
50+
51+ let releaseDocsMsg = """ This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?"""
52+
53+ /// Executes a dotnet command in the given working directory
54+ let runDotNet cmd workingDir =
55+ let result =
56+ DotNet.exec ( DotNet.Options.withWorkingDirectory workingDir) cmd " "
57+ if result.ExitCode <> 0 then failwithf " 'dotnet %s ' failed in %s " cmd workingDir
58+
59+ /// Metadata about the project
60+ module ProjectInfo =
61+
62+ let project = " BioFSharp.BioDB"
63+
64+ let summary = " Programmatic access to Biological Databases from F#"
65+
66+ let configuration = " Release"
67+
68+ // Git configuration (used for publishing documentation in gh-pages branch)
69+ // The profile where the project is posted
70+ let gitOwner = " CSBiology"
71+ let gitName = " BioFSharp.BioDB"
72+
73+ let gitHome = sprintf " %s /%s " " https://github.com" gitOwner
74+
75+ let projectRepo = sprintf " %s /%s /%s " " https://github.com" gitOwner gitName
76+
77+ let website = " /BioFSharp.BioDB"
78+
79+ let testProject = " tests/BioFSharp.BioDB.Tests/BioFSharp.BioDB.Tests.fsproj"
80+
81+ let pkgDir = " pkg"
82+
83+ let release = ReleaseNotes.load " RELEASE_NOTES.md"
84+
85+ let stableVersion = SemVer.parse release.NugetVersion
86+
87+ let stableVersionTag = ( sprintf " %i .%i .%i " stableVersion.Major stableVersion.Minor stableVersion.Patch )
88+
89+ let mutable prereleaseSuffix = " "
90+
91+ let mutable prereleaseTag = " "
92+
93+ let mutable isPrerelease = false
94+
95+ /// Barebones, minimal build tasks
96+ module BasicTasks =
97+
98+ open ProjectInfo
99+
100+ let setPrereleaseTag = BuildTask.create " SetPrereleaseTag" [] {
101+ printfn " Please enter pre-release package suffix"
102+ let suffix = System.Console.ReadLine()
103+ prereleaseSuffix <- suffix
104+ prereleaseTag <- ( sprintf " %s -%s " release.NugetVersion suffix)
105+ isPrerelease <- true
106+ }
107+
108+ let clean = BuildTask.create " Clean" [] {
109+ !! " src/**/bin"
110+ ++ " src/**/obj"
111+ ++ " pkg"
112+ ++ " bin"
113+ |> Shell.cleanDirs
114+ }
115+
116+ let build = BuildTask.create " Build" [ clean] {
117+ !! " src/**/*.*proj"
118+ |> Seq.iter ( DotNet.build id)
119+ }
120+
121+ let copyBinaries = BuildTask.create " CopyBinaries" [ clean; build] {
122+ let targets =
123+ !! " src/**/*.??proj"
124+ -- " src/**/*.shproj"
125+ |> Seq.map ( fun f -> (( Path.getDirectory f) </> " bin" </> configuration, " bin" </> ( Path.GetFileNameWithoutExtension f)))
126+ for i in targets do printfn " %A " i
127+ targets
128+ |> Seq.iter ( fun ( fromDir , toDir ) -> Shell.copyDir toDir fromDir ( fun _ -> true ))
129+ }
130+
131+ /// Test executing build tasks
132+ module TestTasks =
133+
134+ open ProjectInfo
135+ open BasicTasks
136+
137+ let runTests = BuildTask.create " RunTests" [ clean; build; copyBinaries] {
138+ let standardParams = Fake.DotNet.MSBuild.CliArguments.Create ()
139+ Fake.DotNet.DotNet.test( fun testParams ->
140+ {
141+ testParams with
142+ Logger = Some " console;verbosity=detailed"
143+ }
144+ ) testProject
145+ }
146+
147+ open BasicTasks
148+ BuildTask.runOrDefault copyBinaries
0 commit comments