-
Notifications
You must be signed in to change notification settings - Fork 0
/
Build.fsx
155 lines (123 loc) · 4.25 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
// include Fake lib
#r @"./Tools/FAKE.Core/tools/FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open System.IO
open System.Linq
let authors = ["Nripendra Nath Newa"]
let assemblyGuid = "119618c8-98cd-477a-b42f-295256cc95a5"
let copyRight = "Copyright © 2014 - Nripendra Nath Newa"
let projectName = "xGherkin.net"
let projectDescription = "xGherkin.net is a xspec flavored BDD framework, which tries to strike balance between xspec and xbehave nature. The basic goal of this project is to remain close to plain gherkin as much as feasible given the language constrain (given that we are using c# to write gherkin)."
let projectSummary = "xGherkin.net is a xspec flavored BDD framework that tries to mimic Gherkin syntax as closely as possible."
let packagingRoot = "./packaging/"
let packagingDir = packagingRoot @@ "xGherkin.net"
let releaseNotes =
ReadFile "ReleaseNotes.md"
|> ReleaseNotesHelper.parseReleaseNotes
let baseDir = "./"
let assemblyInfoPath = baseDir + "Src/Properties/AssemblyInfo.cs"
let outdir = baseDir + "Src/Bin/Release"
let testDir = baseDir + "Tests/xGherkinTests/Bin/Release"
let packageDir = baseDir + "lib/net35"
let nuspecFile = baseDir + "nuspec"
let rec runWithRetries f retries =
if retries <= 0 then
f()
else
try
f()
with
| exn -> runWithRetries f (retries-1)
// Targets
Target "Clean" (fun _ ->
CleanDirs [outdir; testDir;]
)
RestorePackages()
open Fake.AssemblyInfoFile
Target "AssemblyInfo" (fun _ ->
CreateCSharpAssemblyInfo assemblyInfoPath
[Attribute.Title projectName
Attribute.Description projectDescription
Attribute.Guid assemblyGuid
Attribute.Product projectName
Attribute.Copyright copyRight
Attribute.ComVisible false
Attribute.Version releaseNotes.AssemblyVersion
Attribute.InformationalVersion (releaseNotes.SemVer.ToString())
Attribute.FileVersion releaseNotes.AssemblyVersion]
)
Target "RestorePackages" (fun _ ->
"./Src/packages.config"
|> RestorePackage (fun p ->
{ p with
Retries = 2 })
"./.nuget/packages.config"
|> RestorePackage (fun p ->
{ p with
Retries = 2 })
"./Tests/xGherkinTests/packages.config"
|> RestorePackage (fun p ->
{ p with
Retries = 2 })
)
//Build Main project
Target "Build" (fun _ ->
!! "Src/*.csproj"
|> MSBuildRelease outdir "Build"
|> Log "AppBuild-Output: "
)
Target "BuildTest" (fun _ ->
!! "Tests/xGherkinTests/*.csproj"
|> MSBuildRelease testDir "Build"
|> Log "TestBuild-Output: "
)
Target "Test" (fun _ ->
!! (testDir @@ @"xGherkinTests.dll")
|> xUnit (fun p -> {p with
OutputDir = testDir
HtmlOutput = true })
)
Target "CreatePackage" (fun _ ->
let net35Dir = packagingDir @@ "lib/net35/"
CleanDirs [packagingRoot]
CleanDirs [net35Dir]
// Copy all the package files into a package folder
CopyFile net35Dir (outdir @@ "xGherkin.dll")
CopyFile net35Dir (outdir @@ "xGherkin.pdb")
CopyFile net35Dir (outdir @@ "xGherkin.dll.config")
CopyFiles packagingDir ["LICENSE"; "README.md"; "ReleaseNotes.md"]
NuGet (fun p ->
{p with
Authors = authors
Project = projectName
Description = projectDescription
OutputPath = packagingRoot
Summary = projectSummary
WorkingDir = packagingDir
Version = releaseNotes.SemVer.ToString()
ReleaseNotes = toLines releaseNotes.Notes
//AccessKey = myAccesskey
Dependencies =
["xunit", GetPackageVersion "./packages/" "xunit"]
Publish = false })
"xGherkin.net.nuspec"
)
// Default target
Target "Default" (fun _ ->
trace "Completed Build!!"
)
Target "TestReport" (fun _ ->
ignore(System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(testDir @@ @"xGherkinTests.dll.html")))
)
"Clean"
==> "AssemblyInfo"
==> "RestorePackages"
==> "Build"
==> "BuildTest"
==> "Test"
==> "CreatePackage"
==> "Default"
==> "TestReport"
// start build
RunTargetOrDefault "Default"