-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.fsx
139 lines (110 loc) · 3.91 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
// include libs
#r "./packages/build-gr/FAKE/tools/FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
// Directories
let nupkgFolder = "./nupkg"
// The name of the project
// (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src')
let project = "Hopac.IO"
// Short summary of the project
// (used as description in AssemblyInfo and as a short summary for NuGet package)
let summary = "Extensions for standard IO operations with Hopac Jobs"
// Pattern specifying assemblies to be tested using NUnit
let testAssemblies = "tests/**/*.??proj"
// Default target configuration
let configuration = "Release"
// Read additional information from the release notes document
let release = LoadReleaseNotes "RELEASE_NOTES.md"
// File system information
let solutionFile = "Hopac.IO.sln"
//Paket template to generate Nuspec
let nugetTemplate = "src/Hopac.IO/paket.template"
// Generate assembly info files with the right version & up-to-date information
Target "AssemblyInfo" (fun _ ->
let getAssemblyInfoAttributes projectName =
[ Attribute.Title projectName
Attribute.Product project
Attribute.Description summary
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion
Attribute.Configuration configuration ]
let getProjectDetails projectPath =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
( projectPath,
projectName,
System.IO.Path.GetDirectoryName(projectPath),
(getAssemblyInfoAttributes projectName)
)
!! "src/**/*.??proj"
|> Seq.map getProjectDetails
|> Seq.iter (fun (projFileName, _, folderName, attributes) ->
match projFileName with
| Fsproj -> CreateFSharpAssemblyInfo (folderName </> "AssemblyInfo.fs") attributes
| Csproj -> CreateCSharpAssemblyInfo ((folderName </> "Properties") </> "AssemblyInfo.cs") attributes
| Vbproj -> CreateVisualBasicAssemblyInfo ((folderName </> "My Project") </> "AssemblyInfo.vb") attributes
| Shproj -> ()
)
)
// --------------------------------------------------------------------------------------
// Clean build results
Target "Clean" (fun _ ->
!! "src/**/bin"
++ nupkgFolder
|> CleanDirs
)
// --------------------------------------------------------------------------------------
// Build library
Target "Build" (fun _ ->
!! solutionFile
|> Seq.iter (fun slnPath ->
DotNetCli.Build ( fun p ->
{ p with
WorkingDir = "./"
Configuration = configuration
Project = slnPath }))
)
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner
Target "RunTests" (fun _ ->
!! testAssemblies
|> Seq.iter (fun testDll ->
DotNetCli.Test (fun p ->
{ p with Project = testDll }
)
)
)
// --------------------------------------------------------------------------------------
// Build a NuGet package
Target "NuGet" (fun _ ->
Paket.Pack(fun p ->
{ p with
MinimumFromLockFile = true
OutputPath = nupkgFolder
Version = release.NugetVersion
ReleaseNotes = toLines release.Notes})
)
// --------------------------------------------------------------------------------------
// Publish package to nuget.org
Target "PublishNuget" (fun _ ->
Paket.Push(fun p ->
{ p with
WorkingDir = nupkgFolder })
)
// Target for build + package publish
Target "All" DoNothing
// Target for build only
Target "JustBuild" DoNothing
// Build order
"AssemblyInfo"
==> "Clean"
==> "Build"
==> "RunTests"
==> "JustBuild"
"JustBuild"
==> "NuGet"
==> "PublishNuget"
==> "All"
// Default build
RunTargetOrDefault "JustBuild"