1- // Include Fake library
21#r " ./packages/FAKE/tools/FakeLib.dll"
32
43open Fake
5- open Fake.Testing . XUnit2
4+ open Fake.DotNetCli
65
7- // Directories
8- let buildDir = " ./build/"
9- let sourceDir = " ./exercises/"
6+ let buildDir = " ./build/"
7+ let sourceDir = " ./exercises/"
8+ let projects = !! ( buildDir @@ " */*.csproj" )
9+ let tests = !! ( buildDir @@ " **/*Test.cs" )
1010
11- // Files
12- let solutionFile = buildDir @@ " /exercises.csproj "
13- let compiledOutput = buildDir @@ " xcsharp.dll "
11+ let restore project = DotNetCli.Restore ( fun p ->
12+ { p with NoCache = true
13+ Project = project })
1414
15- // Targets
16- Target " PrepareUnchanged" ( fun _ ->
17- CleanDirs [ buildDir]
18- CopyDir buildDir sourceDir allFiles
19- )
15+ let build project = DotNetCli.Build ( fun p ->
16+ { p with Project = project })
2017
21- Target " BuildUnchanged" ( fun _ ->
22- MSBuildRelease buildDir " Build" [ solutionFile]
23- |> Log " Build unchanged output: "
24- )
18+ let test project = DotNetCli.Test ( fun p ->
19+ { p with Project = project })
2520
26- Target " PrepareTests " ( fun _ ->
27- CleanDirs [ buildDir ]
28- CopyDir buildDir sourceDir allFiles
21+ let restoreAndBuild project =
22+ restore project
23+ build project
2924
30- let ignorePattern = " Skip\s *=\s *\" Remove to run test\" "
25+ let restoreAndTest project =
26+ restore project
27+ test project
3128
32- !! ( buildDir @@ " **/*Test.cs " )
33- |> RegexReplaceInFilesWithEncoding ignorePattern " " System.Text.Encoding.UTF8
29+ Target " Clean " ( fun _ ->
30+ CleanDirs [ buildDir ]
3431)
3532
36- Target " BuildTests" ( fun _ ->
37- MSBuildRelease buildDir " Build" [ solutionFile]
38- |> Log " Build tests output: "
33+ Target " Copy" ( fun _ ->
34+ CopyDir buildDir sourceDir allFiles
3935)
4036
4137Target " Test" ( fun _ ->
42- [ compiledOutput]
43- |> xUnit2 ( fun p -> { p with ShadowCopy = false })
38+ let ignorePattern = " Skip\s *=\s *\" Remove to run test\" "
39+ RegexReplaceInFilesWithEncoding ignorePattern " " System.Text.Encoding.UTF8 tests
40+
41+ Seq.iter restoreAndTest projects
4442)
4543
46- // Build order
47- " PrepareUnchanged"
48- ==> " BuildUnchanged"
49- ==> " PrepareTests"
50- ==> " BuildTests"
44+ " Clean"
45+ ==> " Copy"
5146 ==> " Test"
5247
53- // start build
5448RunTargetOrDefault " Test"
0 commit comments