Skip to content

Commit 2343a83

Browse files
committed
add test fixtures and small fixes
1 parent 27c71b1 commit 2343a83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3466
-7
lines changed

BuildProject.fsproj

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,19 @@
1212
<Title>BuildProject</Title>
1313
<Authors>Kevin Schneider</Authors>
1414
<Description>A template for scaffolding a modern build pipeline for your project using FAKE and .NET 6/7</Description>
15-
<Summary>scaffold a FAKE + .net6/7 build project</Summary>
15+
<Summary>scaffold a FAKE + .net6/7/8 build project</Summary>
1616
<PackageReadmeFile>README.md</PackageReadmeFile>
1717
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1818
<PackageProjectUrl>https://github.com/kMutagene/BuildProject</PackageProjectUrl>
1919
<PackageTags>build f#</PackageTags>
2020
<RepositoryUrl>https://github.com/kMutagene/BuildProject</RepositoryUrl>
2121
<RepositoryType>git</RepositoryType>
22-
<PackageVersion>3.1.0</PackageVersion>
23-
<PackageReleaseNotes>fix conditional runTests target</PackageReleaseNotes>
22+
<PackageVersion>4.0.0</PackageVersion>
23+
<PackageReleaseNotes>
24+
- support .net8.0
25+
- proper choice flag for tfm
26+
- disable internal binlog everywhere
27+
</PackageReleaseNotes>
2428
</PropertyGroup>
2529
<PropertyGroup>
2630
<ExcludeFromPackage>

Content/BasicTasks.fs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ let buildSolution =
5050
MSBuildParams = msBuildParams
5151

5252
}
53+
#if( target-framework == "net8.0" )
5354
|> DotNet.Options.withCustomParams (Some "-tl")
55+
#endif
5456
)
5557
}
5658

@@ -85,7 +87,7 @@ let build = BuildTask.create "Build" [clean] {
8587
}
8688
// Use this if you want to speed up your build. Especially helpful in large projects
8789
// Ensure that the order in your project list is correct (e.g. projects that are depended on are built first)
88-
#if ( target-framework == "net8.0" )
90+
#if( target-framework == "net8.0" )
8991
|> DotNet.Options.withCustomParams (Some "--no-dependencies -tl")
9092
#else
9193
|> DotNet.Options.withCustomParams (Some "--no-dependencies")
@@ -110,7 +112,7 @@ let buildSolution =
110112
solutionFile
111113
|> DotNet.build (fun p ->
112114
{ p with MSBuildParams = { p.MSBuildParams with DisableInternalBinLog = true }}
113-
#if ( target-framework == "net8.0" )
115+
#if( target-framework == "net8.0" )
114116
|> DotNet.Options.withCustomParams (Some "-tl")
115117
#endif
116118
)

Content/ProjectInfo.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ let projects =
6464

6565
let project = "{PROJECTNAME}"
6666

67-
let testProjects : string list=
67+
let testProjects =
6868
[
6969
// add relative paths (from project root) to your testprojects here
7070
#if (individual-package-versions)

Content/ReleaseTasks.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ let prereleaseDocs = BuildTask.create "PrereleaseDocs" [buildDocsPrerelease] {
146146
else failwith "aborted"
147147
}
148148
#else
149-
let createTag = BuildTask.create "CreateTag" [clean; build; runTests; pack] {
149+
let createTag = BuildTask.create "CreateTag" [clean; buildSolution; runTests; pack] {
150150
if promptYesNo (sprintf "tagging branch with %s OK?" stableVersionTag ) then
151151
Git.Branches.tag "" stableVersionTag
152152
Git.Branches.pushTag "" projectRepo stableVersionTag
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.0.31903.59
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net6.0", "net6.0", "{B71F5C83-6900-41ED-A168-0DFDB7B50862}"
7+
EndProject
8+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "basic", "basic", "{5A0EAFBA-CB49-47BA-964E-BF30CC602A68}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "advanced", "advanced", "{7CCE8ED1-4DFC-4262-A2F0-6A6AC9696AD2}"
11+
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net7.0", "net7.0", "{19714641-20E5-426A-AEAC-16D9EA215A14}"
13+
EndProject
14+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net8.0", "net8.0", "{59F75FA2-6BD3-42FC-957F-791763EFA895}"
15+
EndProject
16+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "advanced", "advanced", "{808708B0-4066-4787-A6B6-355966BBA06F}"
17+
EndProject
18+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "basic", "basic", "{4A6CF790-C7E1-43AE-AF63-47FD98BD44F6}"
19+
EndProject
20+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "advanced", "advanced", "{E46A08E0-123E-4534-A8BC-621D4CD7BFB2}"
21+
EndProject
22+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "basic", "basic", "{1AF4C1FB-FEE5-4B28-B10A-FA84FC32AD72}"
23+
EndProject
24+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "net6.0\advanced\build.fsproj", "{175EAAB6-AA45-4A6F-945E-004AFC08B9D4}"
25+
EndProject
26+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "net6.0\basic\build.fsproj", "{00B8B642-44E4-4D3F-A5B5-40F94B706687}"
27+
EndProject
28+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "net7.0\advanced\build.fsproj", "{4A87678A-95A9-47B5-A640-2081ED5729DF}"
29+
EndProject
30+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "net7.0\basic\build.fsproj", "{07DD6173-41A7-4F60-BA29-E9AD0FE20D6A}"
31+
EndProject
32+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "net8.0\advanced\build.fsproj", "{6FC160C9-AB5A-459C-BC43-E0915305E49E}"
33+
EndProject
34+
Project("{6EC3EE1D-3C4E-46DD-8F32-0CC8E7565705}") = "build", "net8.0\basic\build.fsproj", "{EBF560FE-89B5-495B-B0D5-5C944369401D}"
35+
EndProject
36+
Global
37+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
38+
Debug|Any CPU = Debug|Any CPU
39+
Release|Any CPU = Release|Any CPU
40+
EndGlobalSection
41+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
42+
{175EAAB6-AA45-4A6F-945E-004AFC08B9D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
43+
{175EAAB6-AA45-4A6F-945E-004AFC08B9D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
44+
{175EAAB6-AA45-4A6F-945E-004AFC08B9D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
45+
{175EAAB6-AA45-4A6F-945E-004AFC08B9D4}.Release|Any CPU.Build.0 = Release|Any CPU
46+
{00B8B642-44E4-4D3F-A5B5-40F94B706687}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
47+
{00B8B642-44E4-4D3F-A5B5-40F94B706687}.Debug|Any CPU.Build.0 = Debug|Any CPU
48+
{00B8B642-44E4-4D3F-A5B5-40F94B706687}.Release|Any CPU.ActiveCfg = Release|Any CPU
49+
{00B8B642-44E4-4D3F-A5B5-40F94B706687}.Release|Any CPU.Build.0 = Release|Any CPU
50+
{4A87678A-95A9-47B5-A640-2081ED5729DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
51+
{4A87678A-95A9-47B5-A640-2081ED5729DF}.Debug|Any CPU.Build.0 = Debug|Any CPU
52+
{4A87678A-95A9-47B5-A640-2081ED5729DF}.Release|Any CPU.ActiveCfg = Release|Any CPU
53+
{4A87678A-95A9-47B5-A640-2081ED5729DF}.Release|Any CPU.Build.0 = Release|Any CPU
54+
{07DD6173-41A7-4F60-BA29-E9AD0FE20D6A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
55+
{07DD6173-41A7-4F60-BA29-E9AD0FE20D6A}.Debug|Any CPU.Build.0 = Debug|Any CPU
56+
{07DD6173-41A7-4F60-BA29-E9AD0FE20D6A}.Release|Any CPU.ActiveCfg = Release|Any CPU
57+
{07DD6173-41A7-4F60-BA29-E9AD0FE20D6A}.Release|Any CPU.Build.0 = Release|Any CPU
58+
{6FC160C9-AB5A-459C-BC43-E0915305E49E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
59+
{6FC160C9-AB5A-459C-BC43-E0915305E49E}.Debug|Any CPU.Build.0 = Debug|Any CPU
60+
{6FC160C9-AB5A-459C-BC43-E0915305E49E}.Release|Any CPU.ActiveCfg = Release|Any CPU
61+
{6FC160C9-AB5A-459C-BC43-E0915305E49E}.Release|Any CPU.Build.0 = Release|Any CPU
62+
{EBF560FE-89B5-495B-B0D5-5C944369401D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
63+
{EBF560FE-89B5-495B-B0D5-5C944369401D}.Debug|Any CPU.Build.0 = Debug|Any CPU
64+
{EBF560FE-89B5-495B-B0D5-5C944369401D}.Release|Any CPU.ActiveCfg = Release|Any CPU
65+
{EBF560FE-89B5-495B-B0D5-5C944369401D}.Release|Any CPU.Build.0 = Release|Any CPU
66+
EndGlobalSection
67+
GlobalSection(SolutionProperties) = preSolution
68+
HideSolutionNode = FALSE
69+
EndGlobalSection
70+
GlobalSection(NestedProjects) = preSolution
71+
{5A0EAFBA-CB49-47BA-964E-BF30CC602A68} = {B71F5C83-6900-41ED-A168-0DFDB7B50862}
72+
{7CCE8ED1-4DFC-4262-A2F0-6A6AC9696AD2} = {B71F5C83-6900-41ED-A168-0DFDB7B50862}
73+
{808708B0-4066-4787-A6B6-355966BBA06F} = {19714641-20E5-426A-AEAC-16D9EA215A14}
74+
{4A6CF790-C7E1-43AE-AF63-47FD98BD44F6} = {19714641-20E5-426A-AEAC-16D9EA215A14}
75+
{E46A08E0-123E-4534-A8BC-621D4CD7BFB2} = {59F75FA2-6BD3-42FC-957F-791763EFA895}
76+
{1AF4C1FB-FEE5-4B28-B10A-FA84FC32AD72} = {59F75FA2-6BD3-42FC-957F-791763EFA895}
77+
{175EAAB6-AA45-4A6F-945E-004AFC08B9D4} = {7CCE8ED1-4DFC-4262-A2F0-6A6AC9696AD2}
78+
{00B8B642-44E4-4D3F-A5B5-40F94B706687} = {5A0EAFBA-CB49-47BA-964E-BF30CC602A68}
79+
{4A87678A-95A9-47B5-A640-2081ED5729DF} = {808708B0-4066-4787-A6B6-355966BBA06F}
80+
{07DD6173-41A7-4F60-BA29-E9AD0FE20D6A} = {4A6CF790-C7E1-43AE-AF63-47FD98BD44F6}
81+
{6FC160C9-AB5A-459C-BC43-E0915305E49E} = {E46A08E0-123E-4534-A8BC-621D4CD7BFB2}
82+
{EBF560FE-89B5-495B-B0D5-5C944369401D} = {1AF4C1FB-FEE5-4B28-B10A-FA84FC32AD72}
83+
EndGlobalSection
84+
EndGlobal
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
module BasicTasks
2+
3+
open BlackFox.Fake
4+
open Fake.IO
5+
open Fake.DotNet
6+
open Fake.IO.Globbing.Operators
7+
8+
open ProjectInfo
9+
10+
let clean = BuildTask.create "Clean" [] {
11+
!! "src/**/bin"
12+
++ "src/**/obj"
13+
++ "tests/**/bin"
14+
++ "tests/**/obj"
15+
++ "pkg"
16+
|> Shell.cleanDirs
17+
}
18+
19+
20+
/// Buildtask for setting a prerelease tag (also sets the mutable isPrerelease to true, and the PackagePrereleaseTag of all project infos accordingly.)
21+
let setPrereleaseTag =
22+
BuildTask.create "SetPrereleaseTag" [] {
23+
printfn "Please enter pre-release package suffix"
24+
let suffix = System.Console.ReadLine()
25+
prereleaseSuffix <- suffix
26+
isPrerelease <- true
27+
projects
28+
|> List.iter (fun p ->
29+
p.PackagePrereleaseTag <- (sprintf "%s-%s" p.PackageVersionTag suffix)
30+
)
31+
//
32+
prereleaseTag <- (sprintf "%s-%s" CoreProject.PackageVersionTag suffix)
33+
}
34+
35+
/// builds the solution file (dotnet build solution.sln)
36+
let buildSolution =
37+
BuildTask.create "BuildSolution" [ clean ] {
38+
solutionFile
39+
|> DotNet.build (fun p ->
40+
let msBuildParams =
41+
{p.MSBuildParams with
42+
Properties = ([
43+
"warnon", "3390"
44+
])
45+
DisableInternalBinLog = true
46+
}
47+
{
48+
p with
49+
MSBuildParams = msBuildParams
50+
51+
}
52+
)
53+
}
54+
55+
/// builds the individual project files (dotnet build project.*proj)
56+
///
57+
/// The following MSBuild params are set for each project accordingly to the respective ProjectInfo:
58+
///
59+
/// - AssemblyVersion
60+
///
61+
/// - AssemblyInformationalVersion
62+
///
63+
/// - warnon:3390 for xml doc formatting warnings on compilation
64+
65+
let build = BuildTask.create "Build" [clean] {
66+
projects
67+
|> List.iter (fun pInfo ->
68+
let proj = pInfo.ProjFile
69+
proj
70+
|> DotNet.build (fun p ->
71+
let msBuildParams =
72+
{p.MSBuildParams with
73+
Properties = ([
74+
"AssemblyVersion", pInfo.AssemblyVersion
75+
"InformationalVersion", pInfo.AssemblyInformationalVersion
76+
"warnon", "3390"
77+
])
78+
DisableInternalBinLog = true
79+
}
80+
{
81+
p with
82+
MSBuildParams = msBuildParams
83+
}
84+
// Use this if you want to speed up your build. Especially helpful in large projects
85+
// Ensure that the order in your project list is correct (e.g. projects that are depended on are built first)
86+
|> DotNet.Options.withCustomParams (Some "--no-dependencies")
87+
)
88+
)
89+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
open BlackFox.Fake
2+
open System.IO
3+
open Fake.Core
4+
open Fake.DotNet
5+
open Fake.IO
6+
open Fake.IO.FileSystemOperators
7+
open Fake.IO.Globbing.Operators
8+
open Fake.Tools
9+
10+
open Helpers
11+
12+
initializeContext()
13+
14+
open BasicTasks
15+
open TestTasks
16+
open PackageTasks
17+
open DocumentationTasks
18+
open ReleaseTasks
19+
20+
21+
/// Full release of nuget package, git tag, and documentation for the stable version.
22+
let _release =
23+
BuildTask.createEmpty
24+
"Release"
25+
[clean; build; runTests; pack; buildDocs; createTag; publishNuget; releaseDocs]
26+
27+
/// Full release of nuget package, git tag, and documentation for the prerelease version.
28+
let _preRelease =
29+
BuildTask.createEmpty
30+
"PreRelease"
31+
[setPrereleaseTag; clean; build; runTests; packPrerelease; buildDocsPrerelease; createPrereleaseTag; publishNugetPrerelease; prereleaseDocs]
32+
33+
/// Full release of nuget package for the prerelease version.
34+
let _releaseNoDocs =
35+
BuildTask.createEmpty
36+
"ReleaseNoDocs"
37+
[clean; build; runTests; pack; createTag; publishNuget;]
38+
39+
/// Full release of nuget package for the prerelease version.
40+
let _preReleaseNoDocs =
41+
BuildTask.createEmpty
42+
"PreReleaseNoDocs"
43+
[setPrereleaseTag; clean; build; runTests; packPrerelease; createPrereleaseTag; publishNugetPrerelease]
44+
45+
[<EntryPoint>]
46+
let main args =
47+
runOrDefault buildSolution args
48+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
module DocumentationTasks
2+
3+
open Helpers
4+
open ProjectInfo
5+
open BasicTasks
6+
7+
open BlackFox.Fake
8+
9+
10+
let buildDocs =
11+
BuildTask.create "BuildDocs" [ build ] {
12+
printfn "building docs with stable version %s" stableDocsVersionTag
13+
14+
runDotNet
15+
(sprintf
16+
"fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s"
17+
stableDocsVersionTag)
18+
"./"
19+
}
20+
21+
let buildDocsPrerelease =
22+
BuildTask.create "BuildDocsPrerelease" [ setPrereleaseTag; build ] {
23+
printfn "building docs with prerelease version %s" prereleaseTag
24+
25+
runDotNet
26+
(sprintf
27+
"fsdocs build --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s"
28+
prereleaseTag)
29+
"./"
30+
}
31+
32+
let watchDocs =
33+
BuildTask.create "WatchDocs" [ build ] {
34+
printfn "watching docs with stable version %s" stableDocsVersionTag
35+
36+
runDotNet
37+
(sprintf
38+
"fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s"
39+
stableDocsVersionTag)
40+
"./"
41+
}
42+
43+
let watchDocsPrerelease =
44+
BuildTask.create "WatchDocsPrerelease" [ setPrereleaseTag; build ] {
45+
printfn "watching docs with prerelease version %s" prereleaseTag
46+
47+
runDotNet
48+
(sprintf
49+
"fsdocs watch --eval --clean --properties Configuration=Release --parameters fsdocs-package-version %s"
50+
prereleaseTag)
51+
"./"
52+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
module Helpers
2+
3+
open BlackFox.Fake
4+
open Fake.Core
5+
open Fake.DotNet
6+
7+
let initializeContext () =
8+
let execContext = Context.FakeExecutionContext.Create false "build.fsx" [ ]
9+
Context.setExecutionContext (Context.RuntimeContext.Fake execContext)
10+
11+
/// Executes a dotnet command in the given working directory
12+
let runDotNet cmd workingDir =
13+
let result =
14+
DotNet.exec (DotNet.Options.withWorkingDirectory workingDir) cmd ""
15+
if result.ExitCode <> 0 then failwithf "'dotnet %s' failed in %s" cmd workingDir
16+
17+
let runOrDefault defaultTarget args =
18+
Trace.trace (sprintf "%A" args)
19+
try
20+
match args with
21+
| [| target |] -> Target.runOrDefault target
22+
| arr when args.Length > 1 ->
23+
Target.run 0 (Array.head arr) ( Array.tail arr |> List.ofArray )
24+
| _ -> BuildTask.runOrDefault defaultTarget
25+
0
26+
with e ->
27+
printfn "%A" e
28+
1
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module MessagePrompts
2+
3+
let prompt (msg:string) =
4+
System.Console.Write(msg)
5+
System.Console.ReadLine().Trim()
6+
|> function | "" -> None | s -> Some s
7+
|> Option.map (fun s -> s.Replace ("\"","\\\""))
8+
9+
let rec promptYesNo msg =
10+
match prompt (sprintf "%s [Yn]: " msg) with
11+
| Some "Y" | Some "y" -> true
12+
| Some "N" | Some "n" -> false
13+
| _ -> System.Console.WriteLine("Sorry, invalid answer"); promptYesNo msg
14+
15+
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.
16+
Do you want to continue?"""
17+
18+
let releaseDocsMsg = """This will push the docs to gh-pages. Remember building the docs prior to this. Do you want to continue?"""

0 commit comments

Comments
 (0)