forked from exercism/csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
66 lines (54 loc) · 1.83 KB
/
build.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// Include Fake library
#r "./packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.Testing.NUnit3
// Directories
let buildDir = "./build/"
let sourceDir = "./exercises/"
// Files
let solutionFile = buildDir @@ "/exercises.csproj"
let compiledOutput = buildDir @@ "xcsharp.dll"
let nunitToJunitTransformFile = "./paket-files" @@ "nunit" @@ "nunit-transforms" @@ "nunit3-junit" @@ "nunit3-junit.xslt"
// Targets
Target "PrepareUnchanged" (fun _ ->
CleanDirs [buildDir]
CopyDir buildDir sourceDir allFiles
)
Target "BuildUnchanged" (fun _ ->
MSBuildRelease buildDir "Build" [solutionFile]
|> Log "Build unchanged output: "
)
Target "PrepareTests" (fun _ ->
CleanDirs [buildDir]
CopyDir buildDir sourceDir allFiles
let ignorePattern = "(\[Ignore\(\"Remove to run test\"\)]|, Ignore = \"Remove to run test case\")"
!! (buildDir @@ "**/*Test.cs")
|> RegexReplaceInFilesWithEncoding ignorePattern "" System.Text.Encoding.UTF8
)
Target "BuildTests" (fun _ ->
MSBuildRelease buildDir "Build" [solutionFile]
|> Log "Build tests output: "
)
Target "Test" (fun _ ->
if getEnvironmentVarAsBool "APPVEYOR" then
[compiledOutput]
|> NUnit3 (fun p -> { p with
ShadowCopy = false
ToolPath = "nunit3-console.exe" })
else if getEnvironmentVarAsBool "CIRCLECI" then
[compiledOutput]
|> NUnit3 (fun p -> { p with
ShadowCopy = false
ResultSpecs = [sprintf "junit-results.xml;transform=%s" nunitToJunitTransformFile] })
else
[compiledOutput]
|> NUnit3 (fun p -> { p with ShadowCopy = false })
)
// Build order
"PrepareUnchanged"
==> "BuildUnchanged"
==> "PrepareTests"
==> "BuildTests"
==> "Test"
// start build
RunTargetOrDefault "Test"