Skip to content

Commit 4300f5c

Browse files
Ignore Example.cs in project
This enables us to: - Directly build the exercises from the command-line - Simplify the build script
1 parent 5a8fc26 commit 4300f5c

105 files changed

Lines changed: 424 additions & 19 deletions

File tree

Some content is hidden

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

build.fsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
open Fake
44
open Fake.DotNetCli
5+
open System.Text
56

67
let project = environVarOrDefault "project" "*"
78
let buildDir = "./build/"
@@ -11,7 +12,7 @@ let projectDirs = buildDir @@ project
1112
let testFiles = !! (projectDirs @@ "*Test.cs")
1213
let allProjects = !! (projectDirs @@ "*.csproj")
1314
let 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-
5044
Target "BuildUsingStubImplementation" (fun _ ->
5145
Seq.iter restoreAndBuild defaultProjects
5246
)
5347

5448
Target "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

6153
Target "TestRefactoringProjects" (fun _ ->
@@ -64,11 +56,9 @@ Target "TestRefactoringProjects" (fun _ ->
6456

6557
Target "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"

exercises/accumulate/Accumulate.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/acronym/Acronym.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/all-your-base/AllYourBase.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/allergies/Allergies.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/alphametics/Alphametics.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/anagram/Anagram.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/atbash-cipher/AtbashCipher.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/bank-account/BankAccount.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

exercises/beer-song/BeerSong.csproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
<TargetFramework>netcoreapp1.0</TargetFramework>
66
</PropertyGroup>
77

8+
<ItemGroup>
9+
<Compile Remove="Example.cs" />
10+
</ItemGroup>
11+
812
<ItemGroup>
913
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0-preview-20170217-05" />
1014
<PackageReference Include="xunit" Version="2.2.0-rc4-build3536" />

0 commit comments

Comments
 (0)