22
33open Fake
44open Fake.DotNetCli
5+ open System.Text
56
67let project = environVarOrDefault " project" " *"
78let buildDir = " ./build/"
@@ -11,7 +12,7 @@ let projectDirs = buildDir @@ project
1112let testFiles = !! ( projectDirs @@ " *Test.cs" )
1213let allProjects = !! ( projectDirs @@ " *.csproj" )
1314let defaultProjects =
14- !! ( projectDirs @@ " .csproj" ) --
15+ !! ( projectDirs @@ " * .csproj" ) --
1516 ( projectDirs @@ " DotDsl.csproj" ) --
1617 ( projectDirs @@ " Hangman.csproj" ) --
1718 ( projectDirs @@ " React.csproj" )
@@ -40,22 +41,13 @@ Target "CopyExercises" (fun _ ->
4041 CopyDir buildDir sourceDir allFiles
4142)
4243
43- Target " IgnoreExampleImplementation" ( fun _ ->
44- RegexReplaceInFilesWithEncoding
45- " </PropertyGroup>"
46- " </PropertyGroup><ItemGroup><Compile Remove=\" Example.cs\" /></ItemGroup>"
47- System.Text.Encoding.UTF8 allProjects
48- )
49-
5044Target " BuildUsingStubImplementation" ( fun _ ->
5145 Seq.iter restoreAndBuild defaultProjects
5246)
5347
5448Target " EnableAllTests" ( fun _ ->
55- RegexReplaceInFilesWithEncoding
56- " Skip\s *=\s *\" Remove to run test\" "
57- " "
58- System.Text.Encoding.UTF8 testFiles
49+ let skipProperty = " Skip\s *=\s *\" Remove to run test\" "
50+ RegexReplaceInFilesWithEncoding skipProperty " " Encoding.UTF8 testFiles
5951)
6052
6153Target " TestRefactoringProjects" ( fun _ ->
@@ -64,11 +56,9 @@ Target "TestRefactoringProjects" (fun _ ->
6456
6557Target " ReplaceStubWithExampleImplementation" ( fun _ ->
6658 let replaceStubWithExampleImplementation project =
67- let projectDir = directory project
68- let stubFile = projectDir @@ filename project + " " |> changeExt " .cs"
69- let exampleFile = projectDir @@ " Example.cs"
70-
71- CopyFile stubFile exampleFile
59+ let stubFile = filename project + " " |> changeExt " .cs"
60+ let exampleFile = " Example.cs"
61+ RegexReplaceInFileWithEncoding exampleFile stubFile Encoding.UTF8 project
7262
7363 Seq.iter replaceStubWithExampleImplementation allProjects
7464)
@@ -79,11 +69,10 @@ Target "TestUsingExampleImplementation" (fun _ ->
7969
8070" Clean"
8171 ==> " CopyExercises"
82- ==> " IgnoreExampleImplementation"
8372 ==> " BuildUsingStubImplementation"
8473 ==> " EnableAllTests"
8574 ==> " TestRefactoringProjects"
8675 ==> " ReplaceStubWithExampleImplementation"
8776 ==> " TestUsingExampleImplementation"
8877
89- RunTargetOrDefault " TestUsingExampleImplementation"
78+ RunTargetOrDefault " TestUsingExampleImplementation"
0 commit comments