-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.fsx
137 lines (111 loc) · 3.94 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
// include Fake libs
#I @"packages\FAKE\tools\"
#r @"packages\FAKE\tools\FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open System.IO
open Fake.Paket
open Fake.OpenCoverHelper
open Fake.ReportGeneratorHelper
open Fake.FileHelper
open Fake.Testing.NUnit3
//Project config
let projectName = "Xrm.Oss.FluentQuery"
let projectDescription = "A Dynamics CRM / Dynamics365 library for fluent queries"
let authors = ["Florian Kroenert"]
// Directories
let buildDir = @".\build\"
let libbuildDir = buildDir + @"lib\"
let testDir = @".\test\"
let nUnitPath = "packages" @@ "nunit.consolerunner" @@ "tools" @@ "nunit3-console.exe"
let deployDir = @".\Publish\"
let libdeployDir = deployDir + @"lib\"
let nugetDir = @".\nuget\"
let packagesDir = @".\packages\"
// version info
let mutable majorversion = "2"
let mutable minorversion = "1"
let mutable patch = "3"
let mutable nugetVersion = ""
let mutable asmVersion = ""
let mutable asmInfoVersion = ""
let sha = "" //Git.Information.getCurrentHash()
// Targets
Target "Clean" (fun _ ->
CleanDirs [buildDir; testDir; deployDir; nugetDir]
)
Target "BuildVersions" (fun _ ->
asmVersion <- majorversion + "." + minorversion + "." + patch
asmInfoVersion <- asmVersion + " - " + sha
let nugetBuildNumber = if not isLocalBuild then patch else "0"
nugetVersion <- majorversion + "." + minorversion + "." + nugetBuildNumber
SetBuildNumber nugetVersion // Publish version to TeamCity
)
Target "AssemblyInfo" (fun _ ->
BulkReplaceAssemblyInfoVersions "src" (fun f ->
{f with
AssemblyVersion = asmVersion
AssemblyInformationalVersion = asmInfoVersion
AssemblyFileVersion = asmVersion})
)
Target "BuildLib" (fun _ ->
!! @"src\lib\**\*.csproj"
|> MSBuildRelease libbuildDir "Build"
|> Log "Build-Output: "
)
Target "BuildTest" (fun _ ->
!! @"src\test\**\*.csproj"
|> MSBuildDebug testDir "Build"
|> Log "Build Log: "
)
Target "NUnit" (fun _ ->
let testFiles = !!(testDir @@ @"\**\*.Tests.dll")
if testFiles.Includes.Length <> 0 then
testFiles
|> NUnit3 (fun test ->
{test with
ShadowCopy = false;
ToolPath = nUnitPath;})
)
Target "CodeCoverage" (fun _ ->
OpenCover (fun p -> { p with
TestRunnerExePath = nUnitPath
ExePath ="packages" @@ "OpenCover" @@ "tools" @@ "OpenCover.Console.exe"
Register = RegisterType.RegisterUser
WorkingDir = (testDir)
Filter = "+[Xrm.Oss*]* -[*.Tests*]*"
Output = "../coverage.xml"
}) "Xrm.Oss.FluentQuery.Tests.dll"
)
Target "ReportCodeCoverage" (fun _ ->
ReportGenerator (fun p -> { p with
ExePath = "packages" @@ "ReportGenerator" @@ "tools" @@ "ReportGenerator.exe"
WorkingDir = (testDir)
TargetDir = "../reports"
ReportTypes = [ReportGeneratorReportType.Html; ReportGeneratorReportType.Badges ]
}) [ "..\coverage.xml" ]
)
Target "Publish" (fun _ ->
CreateDir libdeployDir
!! (libbuildDir @@ @"*.*")
|> CopyTo libdeployDir
)
Target "CreateNuget" (fun _ ->
Pack (fun p ->
{p with
Version = nugetVersion
})
)
// Dependencies
"Clean"
==> "BuildVersions"
=?> ("AssemblyInfo", not isLocalBuild )
==> "BuildLib"
==> "BuildTest"
==> "NUnit"
==> "CodeCoverage"
==> "ReportCodeCoverage"
==> "Publish"
==> "CreateNuget"
// start build
RunTargetOrDefault "Publish"