@@ -5,18 +5,21 @@ open Fake.DotNetCli
55
66let buildDir = " ./build/"
77let sourceDir = " ./exercises/"
8- let projects = !! ( buildDir @@ " */*.csproj" )
9- let tests = !! ( buildDir @@ " **/*Test.cs" )
108
11- let restore project = DotNetCli.Restore ( fun p ->
12- { p with NoCache = true
13- Project = project })
9+ let testFiles = !! ( buildDir @@ " */*Test.cs" )
10+ let allProjects = !! ( buildDir @@ " */*.csproj" )
11+ let defaultProjects =
12+ !! ( buildDir @@ " */*.csproj" ) --
13+ ( buildDir @@ " */DotDsl.csproj" ) --
14+ ( buildDir @@ " */React.csproj" )
15+ let refactoringProjects =
16+ !! ( buildDir @@ " */TreeBuilding.csproj" ) ++
17+ ( buildDir @@ " */Ledger.csproj" ) ++
18+ ( buildDir @@ " */Markdown.csproj" )
1419
15- let build project = DotNetCli.Build ( fun p ->
16- { p with Project = project })
17-
18- let test project = DotNetCli.Test ( fun p ->
19- { p with Project = project })
20+ let restore project = DotNetCli.Restore ( fun p -> { p with Project = project })
21+ let build project = DotNetCli.Build ( fun p -> { p with Project = project })
22+ let test project = DotNetCli.Test ( fun p -> { p with Project = project })
2023
2124let restoreAndBuild project =
2225 restore project
@@ -27,22 +30,52 @@ let restoreAndTest project =
2730 test project
2831
2932Target " Clean" ( fun _ ->
30- CleanDirs [ buildDir]
33+ DeleteDir buildDir
3134)
3235
33- Target " Copy " ( fun _ ->
36+ Target " CopyExercises " ( fun _ ->
3437 CopyDir buildDir sourceDir allFiles
3538)
3639
37- Target " Test" ( fun _ ->
38- let ignorePattern = " Skip\s *=\s *\" Remove to run test\" "
39- RegexReplaceInFilesWithEncoding ignorePattern " " System.Text.Encoding.UTF8 tests
40-
41- Seq.iter restoreAndTest projects
40+ Target " IgnoreExampleImplementation" ( fun _ ->
41+ RegexReplaceInFilesWithEncoding
42+ " </PropertyGroup>"
43+ " </PropertyGroup><ItemGroup><Compile Remove=\" Example.cs\" /></ItemGroup>"
44+ System.Text.Encoding.UTF8 allProjects
45+ )
46+
47+ Target " BuildUsingDefaultImplementation" ( fun _ ->
48+ Seq.iter restoreAndBuild defaultProjects
49+ )
50+
51+ Target " EnableAllTests" ( fun _ ->
52+ RegexReplaceInFilesWithEncoding
53+ " Skip\s *=\s *\" Remove to run test\" "
54+ " "
55+ System.Text.Encoding.UTF8 testFiles
56+ )
57+
58+ Target " TestRefactoringProjects" ( fun _ ->
59+ Seq.iter restoreAndTest refactoringProjects
60+ )
61+
62+ Target " TestUsingExampleImplementation" ( fun _ ->
63+ let useExampleInsteadOfDefaultImplementation project =
64+ let projectDir = directory project
65+ let exampleFile = projectDir @@ " Example.cs"
66+ let defaultFile = projectDir @@ filename project + " " |> changeExt " .cs"
67+ CopyFile defaultFile exampleFile
68+
69+ Seq.iter useExampleInsteadOfDefaultImplementation allProjects
70+ Seq.iter restoreAndTest allProjects
4271)
4372
4473" Clean"
45- ==> " Copy"
46- ==> " Test"
74+ ==> " CopyExercises"
75+ ==> " IgnoreExampleImplementation"
76+ ==> " BuildUsingDefaultImplementation"
77+ ==> " EnableAllTests"
78+ ==> " TestRefactoringProjects"
79+ ==> " TestUsingExampleImplementation"
4780
48- RunTargetOrDefault " Test "
81+ RunTargetOrDefault " TestUsingExampleImplementation "
0 commit comments