Skip to content

Commit 53bac71

Browse files
committed
Set up project
1 parent 5b26a03 commit 53bac71

19 files changed

+1966
-0
lines changed

.config/dotnet-tools.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": 1,
3+
"isRoot": true,
4+
"tools": {
5+
"fake-cli": {
6+
"version": "5.20.3",
7+
"commands": [
8+
"fake"
9+
]
10+
}
11+
}
12+
}

BioFSharp.Vis.sln

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 15
4+
VisualStudioVersion = 15.0.26124.0
5+
MinimumVisualStudioVersion = 15.0.26124.0
6+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BioFSharp.Vis", "src\BioFSharp.Vis\BioFSharp.Vis.fsproj", "{83F78860-A189-4EB9-B25B-31AB78B3459D}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{91F8F76D-E6F7-4015-B8AB-2227962ED51D}"
9+
EndProject
10+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "BioFSharp.Vis.Tests", "tests\BioFSharp.Vis.Tests\BioFSharp.Vis.Tests.fsproj", "{E63B30AE-82DC-4AA0-BF47-DB8822F65564}"
11+
EndProject
12+
Global
13+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
14+
Debug|Any CPU = Debug|Any CPU
15+
Debug|x64 = Debug|x64
16+
Debug|x86 = Debug|x86
17+
Release|Any CPU = Release|Any CPU
18+
Release|x64 = Release|x64
19+
Release|x86 = Release|x86
20+
EndGlobalSection
21+
GlobalSection(SolutionProperties) = preSolution
22+
HideSolutionNode = FALSE
23+
EndGlobalSection
24+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
25+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
26+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Debug|Any CPU.Build.0 = Debug|Any CPU
27+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Debug|x64.ActiveCfg = Debug|Any CPU
28+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Debug|x64.Build.0 = Debug|Any CPU
29+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Debug|x86.ActiveCfg = Debug|Any CPU
30+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Debug|x86.Build.0 = Debug|Any CPU
31+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Release|x64.ActiveCfg = Release|Any CPU
34+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Release|x64.Build.0 = Release|Any CPU
35+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Release|x86.ActiveCfg = Release|Any CPU
36+
{83F78860-A189-4EB9-B25B-31AB78B3459D}.Release|x86.Build.0 = Release|Any CPU
37+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
38+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Debug|Any CPU.Build.0 = Debug|Any CPU
39+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Debug|x64.ActiveCfg = Debug|Any CPU
40+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Debug|x64.Build.0 = Debug|Any CPU
41+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Debug|x86.ActiveCfg = Debug|Any CPU
42+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Debug|x86.Build.0 = Debug|Any CPU
43+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Release|Any CPU.ActiveCfg = Release|Any CPU
44+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Release|Any CPU.Build.0 = Release|Any CPU
45+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Release|x64.ActiveCfg = Release|Any CPU
46+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Release|x64.Build.0 = Release|Any CPU
47+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Release|x86.ActiveCfg = Release|Any CPU
48+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564}.Release|x86.Build.0 = Release|Any CPU
49+
EndGlobalSection
50+
GlobalSection(NestedProjects) = preSolution
51+
{E63B30AE-82DC-4AA0-BF47-DB8822F65564} = {91F8F76D-E6F7-4015-B8AB-2227962ED51D}
52+
EndGlobalSection
53+
EndGlobal

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
### 0.0.1 - 2/26/2021

build.fsx

Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
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.Vis"
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.Vis"
72+
73+
let solutionFile = "BioFSharp.Vis.sln"
74+
75+
let gitHome = sprintf "%s/%s" "https://github.com" gitOwner
76+
77+
let projectRepo = sprintf "%s/%s/%s" "https://github.com" gitOwner gitName
78+
79+
let website = "/BioFSharp.Vis"
80+
81+
let testProject = "tests/BioFSharp.Vis.Tests/BioFSharp.Vis.Tests.fsproj"
82+
83+
let pkgDir = "pkg"
84+
85+
let release = ReleaseNotes.load "RELEASE_NOTES.md"
86+
87+
let stableVersion = SemVer.parse release.NugetVersion
88+
89+
let stableVersionTag = (sprintf "%i.%i.%i" stableVersion.Major stableVersion.Minor stableVersion.Patch )
90+
91+
let mutable prereleaseSuffix = ""
92+
93+
let mutable prereleaseTag = ""
94+
95+
let mutable isPrerelease = false
96+
97+
/// Barebones, minimal build tasks
98+
module BasicTasks =
99+
100+
open ProjectInfo
101+
102+
let setPrereleaseTag = BuildTask.create "SetPrereleaseTag" [] {
103+
printfn "Please enter pre-release package suffix"
104+
let suffix = System.Console.ReadLine()
105+
prereleaseSuffix <- suffix
106+
prereleaseTag <- (sprintf "%s-%s" release.NugetVersion suffix)
107+
isPrerelease <- true
108+
}
109+
110+
let clean = BuildTask.create "Clean" [] {
111+
!! "src/**/bin"
112+
++ "src/**/obj"
113+
++ "pkg"
114+
++ "bin"
115+
|> Shell.cleanDirs
116+
}
117+
118+
let restore = BuildTask.create "Restore" [clean] {
119+
!! "src/**/*.*proj"
120+
|> Seq.iter (DotNet.restore id)
121+
}
122+
123+
let build = BuildTask.create "Build" [clean; restore] {
124+
let setParams (defaults:MSBuildParams) =
125+
{ defaults with
126+
Verbosity = Some(Quiet)
127+
Targets = ["Build"]
128+
Properties =
129+
[
130+
"Optimize", "True"
131+
"DebugSymbols", "True"
132+
"Configuration", configuration
133+
"VersionPrefix", release.NugetVersion
134+
if isPrerelease then ("VersionSuffix",prereleaseSuffix)
135+
]
136+
}
137+
MSBuild.build setParams solutionFile
138+
}
139+
140+
let copyBinaries = BuildTask.create "CopyBinaries" [clean; restore; build] {
141+
let targets =
142+
!! "src/**/*.??proj"
143+
-- "src/**/*.shproj"
144+
|> Seq.map (fun f -> ((Path.getDirectory f) </> "bin" </> configuration, "bin" </> (Path.GetFileNameWithoutExtension f)))
145+
for i in targets do printfn "%A" i
146+
targets
147+
|> Seq.iter (fun (fromDir, toDir) -> Shell.copyDir toDir fromDir (fun _ -> true))
148+
}
149+
150+
/// Test executing build tasks
151+
module TestTasks =
152+
153+
open ProjectInfo
154+
open BasicTasks
155+
156+
let testAssemblies = "tests/**/bin" </> configuration </> "**" </> "*Tests.exe"
157+
158+
let runTests = BuildTask.create "runTests" [clean; restore; build; copyBinaries] {
159+
let assemblies = !! testAssemblies
160+
161+
assemblies
162+
|> Seq.iter (fun f ->
163+
Command.RawCommand (
164+
f,
165+
Arguments.OfArgs []
166+
)
167+
|> CreateProcess.fromCommand
168+
|> CreateProcess.withFramework
169+
|> CreateProcess.ensureExitCode
170+
|> Proc.run
171+
|> ignore
172+
)
173+
}
174+
175+
/// Package creation
176+
module PackageTasks =
177+
178+
open ProjectInfo
179+
180+
open BasicTasks
181+
open TestTasks
182+
183+
let pack = BuildTask.create "Pack" [clean; restore; build; runTests; copyBinaries] {
184+
if promptYesNo (sprintf "creating stable package with version %s OK?" stableVersionTag )
185+
then
186+
!! "src/**/*.*proj"
187+
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
188+
let msBuildParams =
189+
{p.MSBuildParams with
190+
Properties = ([
191+
"Version",stableVersionTag
192+
"PackageReleaseNotes", (release.Notes |> String.concat "\r\n")
193+
"TargetFrameworks","net47"
194+
] @ p.MSBuildParams.Properties)
195+
}
196+
{
197+
p with
198+
MSBuildParams = msBuildParams
199+
OutputPath = Some pkgDir
200+
}
201+
))
202+
else failwith "aborted"
203+
}
204+
205+
let packPrerelease = BuildTask.create "PackPrerelease" [setPrereleaseTag; clean; restore; build; runTests; copyBinaries] {
206+
if promptYesNo (sprintf "package tag will be %s OK?" prereleaseTag )
207+
then
208+
!! "src/**/*.*proj"
209+
//-- "src/**/Plotly.NET.Interactive.fsproj"
210+
|> Seq.iter (Fake.DotNet.DotNet.pack (fun p ->
211+
let msBuildParams =
212+
{p.MSBuildParams with
213+
Properties = ([
214+
"Version", prereleaseTag
215+
"PackageReleaseNotes", (release.Notes |> String.toLines )
216+
"TargetFrameworks","net47"
217+
] @ p.MSBuildParams.Properties)
218+
}
219+
{
220+
p with
221+
VersionSuffix = Some prereleaseSuffix
222+
OutputPath = Some pkgDir
223+
MSBuildParams = msBuildParams
224+
}
225+
))
226+
else
227+
failwith "aborted"
228+
}
229+
230+
open BasicTasks
231+
open TestTasks
232+
open PackageTasks
233+
234+
BuildTask.runOrDefault pack

0 commit comments

Comments
 (0)