forked from viagogo/HalKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
106 lines (87 loc) · 3.23 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
#r @"tools/FAKE.Core/tools/FakeLib.dll"
open System
open System.IO
open Fake
open Fake.AssemblyInfoFile
open Fake.Testing
// Project information used to generate AssemblyInfo and .nuspec
let projectName = "HalKit"
let projectDescription = "A lightweight .NET library for creating and consuming HAL hypermedia APIs"
let authors = ["viagogo"]
let copyright = @"Copyright viagogo " + DateTime.UtcNow.ToString("yyyy");
// Directories
let buildDir = @"./artifacts/"
let packagingDir = buildDir @@ "packages"
let testResultsDir = @"./testresults/"
// Read Release Notes and version from ReleaseNotes.md
let releaseNotes =
ReadFile "ReleaseNotes.md"
|> ReleaseNotesHelper.parseReleaseNotes
// Targets
Target "Clean" (fun _ ->
CleanDirs [buildDir; testResultsDir; packagingDir]
)
Target "AssemblyInfo" (fun _ ->
CreateCSharpAssemblyInfo "./SolutionInfo.cs"
[ Attribute.Product projectName
Attribute.Company authors.[0]
Attribute.Copyright copyright
Attribute.Version releaseNotes.AssemblyVersion
Attribute.FileVersion releaseNotes.AssemblyVersion
Attribute.InformationalVersion releaseNotes.NugetVersion
Attribute.ComVisible false ]
)
Target "BuildApp" (fun _ ->
let buildMode = getBuildParamOrDefault "buildMode" "Release"
RestorePackages()
MSBuild buildDir "Build" ["Configuration", buildMode] ["./HalKit.sln"]
|> Log "AppBuild-Output: "
)
Target "UnitTests" (fun _ ->
!! (buildDir + @"\HalKit*.Tests.dll")
|> xUnit2 (fun p ->
{p with
HtmlOutputPath = Some (testResultsDir @@ "xunit.html")}
)
)
Target "CreatePackage" (fun _ ->
let tags = "HAL Hypermedia API REST viagogo"
let dependencies = [
("Microsoft.Net.Http", GetPackageVersion "./packages/" "Microsoft.Net.Http")
("Newtonsoft.Json", GetPackageVersion "./packages/" "Newtonsoft.Json")
("Tavis.UriTemplates", GetPackageVersion "./packages/" "Tavis.UriTemplates")
]
let inline nugetFriendlyPath (path : string) = if path.StartsWith("./") then path.Remove(0, 2) else path
let libPortableDir = "lib/portable-net45+win+wpa81+wp80+MonoAndroid10+xamarinios10+MonoTouch10/"
let files = [
(nugetFriendlyPath buildDir @@ "HalKit.dll", Some libPortableDir, None)
(nugetFriendlyPath buildDir @@ "HalKit.pdb", Some libPortableDir, None)
(nugetFriendlyPath buildDir @@ "HalKit.xml", Some libPortableDir, None)
("LICENSE.txt", None, None)
("README.md", None, None)
("ReleaseNotes.md", None, None)
("src\HalKit\**\*.cs", Some "src", None)
]
NuGet (fun p ->
{p with
Project = projectName
Description = projectDescription
Copyright = copyright
Authors = authors
OutputPath = packagingDir
WorkingDir = @"."
SymbolPackage = NugetSymbolPackage.Nuspec
Version = releaseNotes.NugetVersion
ReleaseNotes = toLines releaseNotes.Notes
Dependencies = dependencies
Files = files}) "HalKit.nuspec"
)
Target "CreatePackages" DoNothing
"Clean"
==> "AssemblyInfo"
==> "BuildApp"
==> "UnitTests"
==> "CreatePackage"
"CreatePackage"
==> "CreatePackages"
RunTargetOrDefault "BuildApp"