-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathbuild.fsx
146 lines (130 loc) · 4.44 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
#r "FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open Fake.EnvironmentHelper
open Fake.MSBuildHelper
open Fake.NuGetHelper
open Fake.Testing
// properties
let semanticVersion = "4.0.0"
let version = (>=>) @"(?<major>\d*)\.(?<minor>\d*)\.(?<build>\d*).*?" "${major}.${minor}.${build}.0" semanticVersion
let configuration = getBuildParamOrDefault "configuration" "Release"
// can be set by passing: -ev deployToNuGet true
let deployToNuGet = getBuildParamOrDefault "deployToNuGet" "false"
let genDir = "Gen/"
let docDir = "Doc/"
let srcDir = "Src/"
let testDir = genDir @@ "Test"
let nugetDir = genDir @@ "NuGet"
Target "Clean" (fun _ ->
CleanDirs[genDir; testDir; nugetDir]
build (fun p ->
{ p with
Verbosity = Some(Quiet)
Targets = ["Clean"]
Properties = ["Configuration", configuration]
})
(srcDir @@ "HelperTrinity.sln")
)
// would prefer to use the built-in RestorePackages function, but it restores packages in the root dir (not in Src), which causes build problems
Target "RestorePackages" (fun _ ->
!! "./**/packages.config"
|> Seq.iter (
RestorePackage (fun p ->
{ p with
OutputPath = (srcDir @@ "packages")
})
)
)
Target "Build" (fun _ ->
// generate the shared assembly info
CreateCSharpAssemblyInfoWithConfig (srcDir @@ "AssemblyInfoCommon.cs")
[
Attribute.Version version
Attribute.FileVersion version
Attribute.Configuration configuration
Attribute.Company "Kent Boogaart"
Attribute.Product "The Helper Trinity"
Attribute.Copyright "© Copyright. Kent Boogaart."
Attribute.Trademark ""
Attribute.Culture ""
Attribute.CLSCompliant true
Attribute.StringAttribute("NeutralResourcesLanguage", "en-US", "System.Resources")
Attribute.StringAttribute("AssemblyInformationalVersion", semanticVersion, "System.Reflection")
]
(AssemblyInfoFileConfig(false))
build (fun p ->
{ p with
Verbosity = Some(Quiet)
Targets = ["Build"]
Properties =
[
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", configuration
]
})
(srcDir @@ "HelperTrinity.sln")
)
Target "ExecuteUnitTests" (fun _ ->
xUnit2 (fun p ->
{ p with
ShadowCopy = false;
// HtmlOutputPath = Some testDir;
// XmlOutputPath = Some testDir;
})
[
srcDir @@ "HelperTrinity.UnitTests/bin" @@ configuration @@ "HelperTrinity.UnitTests.dll"
]
)
Target "CreateArchives" (fun _ ->
// source archive
!! "**/*.*"
-- ".git/**"
-- (genDir @@ "**")
-- (srcDir @@ "packages/**/*")
-- (srcDir @@ "**/*.suo")
-- (srcDir @@ "**/*.csproj.user")
-- (srcDir @@ "**/*.gpState")
-- (srcDir @@ "**/bin/**")
-- (srcDir @@ "**/obj/**")
|> Zip "." (genDir @@ "TheHelperTrinity-" + semanticVersion + "-src.zip")
// binary archive
let workingDir = srcDir @@ "HelperTrinity/bin" @@ configuration
!! (workingDir @@ "HelperTrinity.*")
|> Zip workingDir (genDir @@ "TheHelperTrinity-" + semanticVersion + "-bin.zip")
)
Target "CreateNuGetPackages" (fun _ ->
// copy binaries to lib
!! (srcDir @@ "HelperTrinity/bin" @@ configuration @@ "HelperTrinity.*")
|> CopyFiles (nugetDir @@ "lib/netstandard1.0")
// copy source to src
[!! (srcDir @@ "**/*.*")
-- (srcDir @@ "HelperTrinity.UnitTests/**/*")
-- (srcDir @@ "packages/**/*")
-- (srcDir @@ "**/*.suo")
-- (srcDir @@ "**/*.csproj.user")
-- (srcDir @@ "**/*.gpState")
-- (srcDir @@ "**/bin/**")
-- (srcDir @@ "**/obj/**")]
|> CopyWithSubfoldersTo nugetDir
// create the NuGets
NuGet (fun p ->
{p with
Project = "HelperTrinity"
Version = semanticVersion
OutputPath = nugetDir
WorkingDir = nugetDir
SymbolPackage = NugetSymbolPackage.Nuspec
Publish = System.Convert.ToBoolean(deployToNuGet)
})
(srcDir @@ "HelperTrinity.nuspec")
)
// build order
"Clean"
==> "RestorePackages"
==> "Build"
==> "ExecuteUnitTests"
==> "CreateArchives"
==> "CreateNuGetPackages"
RunTargetOrDefault "CreateNuGetPackages"