forked from Topshelf/Topshelf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
194 lines (162 loc) · 6.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#r @"src/packages/FAKE/tools/FakeLib.dll"
open System.IO
open Fake
open Fake.AssemblyInfoFile
open Fake.Git.Information
open Fake.SemVerHelper
let buildOutputPath = "./build_output"
let buildArtifactPath = "./build_artifacts"
let nugetWorkingPath = FullName "./build_temp"
let packagesPath = FullName "./src/packages"
let keyFile = FullName "./Topshelf.snk"
let assemblyVersion = "4.0.0.0"
let baseVersion = "4.0.1"
let semVersion : SemVerInfo = parse baseVersion
let Version = semVersion.ToString()
let branch = (fun _ ->
(environVarOrDefault "APPVEYOR_REPO_BRANCH" (getBranchName "."))
)
let FileVersion = (environVarOrDefault "APPVEYOR_BUILD_VERSION" (Version + "." + "0"))
let informationalVersion = (fun _ ->
let branchName = (branch ".")
let label = if branchName="master" then "" else " (" + branchName + "/" + (getCurrentSHA1 ".").[0..7] + ")"
(FileVersion + label)
)
let nugetVersion = (fun _ ->
let branchName = (branch ".")
let label = if branchName="master" then "" else "-" + (if branchName="mt3" then "beta" else branchName)
(Version + label)
)
let InfoVersion = informationalVersion()
let NuGetVersion = nugetVersion()
printfn "Using version: %s" Version
Target "Clean" (fun _ ->
ensureDirectory buildOutputPath
ensureDirectory buildArtifactPath
ensureDirectory nugetWorkingPath
CleanDir buildOutputPath
CleanDir buildArtifactPath
CleanDir nugetWorkingPath
)
Target "RestorePackages" (fun _ ->
"./src/Topshelf.sln"
|> RestoreMSSolutionPackages (fun p ->
{ p with
OutputPath = packagesPath
Retries = 4 })
)
Target "Build" (fun _ ->
CreateCSharpAssemblyInfo @".\src\SolutionVersion.cs"
[ Attribute.Title "Topshelf"
Attribute.Description "Topshelf is an open source project for hosting services without friction. By referencing Topshelf, your console application *becomes* a service installer with a comprehensive set of command-line options for installing, configuring, and running your application as a service."
Attribute.Product "Topshelf"
Attribute.Version assemblyVersion
Attribute.FileVersion FileVersion
Attribute.InformationalVersion InfoVersion
Attribute.Copyright "Copyright 2012 Chris Patterson, Dru Sellers, Travis Smith, All rights reserved."
]
let buildMode = getBuildParamOrDefault "buildMode" "Release"
let setParams defaults = {
defaults with
Verbosity = Some(Quiet)
Targets = ["Clean"; "Build"]
Properties =
[
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", buildMode
"TargetFrameworkVersion", "v4.5.2"
"Platform", "Any CPU"
]
}
build setParams @".\src\Topshelf.sln"
|> DoNothing
let unsignedSetParams defaults = {
defaults with
Verbosity = Some(Quiet)
Targets = ["Build"]
Properties =
[
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", "ReleaseUnsigned"
"TargetFrameworkVersion", "v4.5.2"
"Platform", "Any CPU"
]
}
build unsignedSetParams @".\src\Topshelf.sln"
|> DoNothing
)
let testDlls = !! ("./src/Topshelf.Tests/bin/Release/*.Tests.dll")
Target "UnitTests" (fun _ ->
testDlls
|> NUnit (fun p ->
{p with
Framework = "v4.0.30319"
DisableShadowCopy = true;
OutputFile = buildArtifactPath + "/nunit-test-results.xml"})
)
type packageInfo = {
Project: string
PackageFile: string
Summary: string
Files: list<string*string option*string option>
}
Target "Package" (fun _ ->
let nugs = [| { Project = "Topshelf"
Summary = "Topshelf Service Library"
PackageFile = @".\src\Topshelf\packages.config"
Files = [ (@"..\src\Topshelf\bin\Release\Topshelf.*", Some @"lib\net452", None);
(@"..\src\Topshelf\**\*.cs", Some "src", None) ] }
{ Project = "Topshelf.Log4Net"
Summary = "Topshelf Log4Net Integration."
PackageFile = @".\src\Topshelf.Log4Net\packages.config"
Files = [ (@"..\src\Topshelf.Log4Net\bin\Release\Topshelf.Log4Net.*", Some @"lib\net452", None);
(@"..\src\Topshelf.Log4Net\**\*.cs", Some @"src", None) ] }
{ Project = "Topshelf.NLog"
Summary = "Topshelf NLog Integration."
PackageFile = @".\src\Topshelf.NLog\packages.config"
Files = [ (@"..\src\Topshelf.NLog\bin\Release\Topshelf.NLog.*", Some @"lib\net452", None);
(@"..\src\Topshelf.NLog\**\*.cs", Some @"src", None) ] }
{ Project = "Topshelf.Elmah"
Summary = "Topshelf Elmah Integration."
PackageFile = @".\src\Topshelf.Elmah\packages.config"
Files = [ (@"..\src\Topshelf.Elmah\bin\Release\Topshelf.Elmah.*", Some @"lib\net452", None);
(@"..\src\Topshelf.Elmah\**\*.cs", Some @"src", None) ] }
{ Project = "Topshelf.Serilog"
Summary = "Topshelf Serilog Integration."
PackageFile = @".\src\Topshelf.Serilog\packages.config"
Files = [ (@"..\src\Topshelf.Serilog\bin\Release\Topshelf.Serilog.*", Some @"lib\net452", None);
(@"..\src\Topshelf.Serilog\**\*.cs", Some @"src", None) ] }
|]
nugs
|> Array.iter (fun nug ->
let getDeps daNug : NugetDependencies =
if daNug.Project = "Topshelf" then (getDependencies daNug.PackageFile)
else ("Topshelf", NuGetVersion) :: (getDependencies daNug.PackageFile)
let setParams defaults = {
defaults with
Authors = ["Chris Patterson"; "Dru Sellers"; "Travis Smith"; "Brian Wilson"; "Mogens Heller Grabe"]
Description = "Topshelf is an open source project for hosting services without friction. By referencing Topshelf, your console application *becomes* a service installer with a comprehensive set of command-line options for installing, configuring, and running your application as a service."
OutputPath = buildArtifactPath
Project = nug.Project
Dependencies = (getDeps nug)
Summary = nug.Summary
SymbolPackage = NugetSymbolPackage.Nuspec
Version = NuGetVersion
WorkingDir = nugetWorkingPath
Files = nug.Files
}
NuGet setParams (FullName "./template.nuspec")
)
)
Target "Default" (fun _ ->
trace "Build starting..."
)
"Clean"
==> "RestorePackages"
==> "Build"
==> "UnitTests"
==> "Package"
==> "Default"
RunTargetOrDefault "Default"