-
Notifications
You must be signed in to change notification settings - Fork 16
/
build.fsx
131 lines (110 loc) · 3.99 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
#I @"packages\FAKE.1.64.7\tools"
#r "FakeLib.dll"
open Fake
// properties
let authors = ["Steffen Forkmann"]
let projectName = "NaturalSpec"
let projectDescription = "NaturalSpec is a .NET UnitTest framework which provides automatically testable specs in natural language."
let buildDir = @".\build\"
let docsDir = @".\Doc\"
let deployDir = @".\deploy\"
let testDir = @".\test\"
let nugetDir = @".\nuget\"
let nugetContentSourceDir = @".\NuGetContent\"
let nugetDocsDir = nugetDir @@ "docs/"
let nugetLibDir = nugetDir @@ "lib/"
let nugetContentDir = nugetDir @@ "Content/"
let packagesDir = @".\packages\"
// tools
let nUnitVersion = GetPackageVersion packagesDir "NUnit.Runners"
let nunitPath = sprintf @"%sNUnit.Runners.%s\tools" packagesDir nUnitVersion
// files
let AppReferences = !+ @"src\app\**\*.*proj" |> Scan
let TestReferences = !+ @"src\test\**\*.*proj" |> Scan
let outputAssemblies =
!+ (buildDir + @"\**\*.dll")
++ (buildDir + @"\**\*.exe")
-- @"\**\*SharpZipLib*"
-- @"\**\*SharpSvn*"
-- "**/nunit.framework.dll"
|> Scan
|> Seq.map FullName
let testAssemblies =
!+ (testDir + @"\Spec.*.dll")
|> Scan
// Targets
Target? Clean <-
fun _ -> CleanDirs [buildDir; deployDir; testDir; docsDir; nugetDir; nugetLibDir]
Target? BuildApp <-
fun _ ->
if not isLocalBuild then
AssemblyInfo
(fun p ->
{p with
CodeLanguage = FSharp;
AssemblyVersion = buildVersion;
AssemblyTitle = projectName;
AssemblyDescription = projectDescription;
Guid = "62F3EDB4-1ED9-415c-A349-510DF60380B5";
OutputFileName = @".\src\app\NaturalSpec\AssemblyInfo.fs"})
MSBuildRelease buildDir "Build" AppReferences
|> Log "AppBuild-Output: "
Target? BuildTest <-
fun _ ->
MSBuildDebug testDir "Build" TestReferences
|> Log "TestBuild-Output: "
Target? Test <-
fun _ ->
NUnit (fun p ->
{p with
ToolPath = nunitPath;
DisableShadowCopy = true;
OutputFile = testDir + @"TestResults.xml"})
testAssemblies
Target? GenerateDocumentation <-
fun _ ->
Docu (fun p ->
{p with
ToolPath = @".\tools\Docu\docu.exe"
TemplatesPath = @".\tools\Docu\templates"
OutputPath = docsDir })
(!+ (buildDir @@ "NaturalSpec.dll") |> Scan)
Target? BuildZip <-
fun _ ->
let artifacts = !+ (buildDir + "\**\*.*") -- "*.zip" |> Scan
let zipFileName = deployDir + sprintf "%s-%s.zip" projectName buildVersion
Zip buildDir zipFileName artifacts
Target? ZipDocumentation <-
fun _ ->
let docFiles =
!+ (docsDir + @"\**\*.*")
|> Scan
let zipFileName = deployDir + sprintf "Documentation-%s.zip" buildVersion
Zip @".\Doc\" zipFileName docFiles
Target "BuildNuGet" (fun _ ->
XCopy docsDir nugetDocsDir
[buildDir @@ "NaturalSpec.dll"
buildDir @@ "NaturalSpec.pdb"]
|> CopyTo nugetLibDir
XCopy nugetContentSourceDir nugetContentDir
NuGet (fun p ->
{p with
Authors = authors
Project = projectName
Description = projectDescription
OutputPath = nugetDir
AccessKey = getBuildParamOrDefault "nugetkey" ""
Publish = hasBuildParam "nugetkey" }) "naturalspec.nuspec"
)
Target? Default <- DoNothing
Target? Deploy <- DoNothing
// Dependencies
For? BuildApp <- Dependency? Clean
For? Test <- Dependency? BuildApp |> And? BuildTest
For? GenerateDocumentation <- Dependency? BuildApp
For? ZipDocumentation <- Dependency? GenerateDocumentation
For? BuildZip <- Dependency? Test
For? Deploy <- Dependency? BuildZip |> And? ZipDocumentation |> And? BuildNuGet
For? Default <- Dependency? Deploy
// start build
RunParameterTargetOrDefault "target" "Default"