forked from SolrNet/SolrNet
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
258 lines (214 loc) · 8.5 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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
#I @"lib"
#r "FakeLib.dll"
#r "Fake.Gallio.dll"
#r "System.Xml.Linq"
#load "fake.fsx"
open System
open System.IO
open System.Xml.Linq
open Fake
open Fake.FileUtils
let version = "0.4.0.2002"
let buildDir = "merged"
let nugetDir = "nuget"
let nugetDocs = nugetDir @@ "content"
let nugetLib = nugetDir @@ "lib"
let docsDir = "docs"
let docsFile = "SolrNet.chm"
let keyFile = pwd() @@ "mausch.snk"
let config = getBuildParamOrDefault "config" "debug"
let target = getBuildParamOrDefault "target" "BuildAll"
let slnBuild sln x =
let strongName =
if File.Exists keyFile
then ["SignAssembly","true"; "AssemblyOriginatorKeyFile",keyFile]
else []
sln |> build (fun p -> { p with
Targets = [x]
Properties = ["Configuration",config] @ strongName })
let mainSln = slnBuild "solrnet.sln"
let sampleSln = slnBuild "SampleSolrApp.sln"
let nuGetBuild = Nu.build version
Target "Clean" <| fun _ ->
mainSln "Clean"
sampleSln "Clean"
rm_rf buildDir
rm_rf nugetDir
Target "Build" <| fun _ -> mainSln "Rebuild"
Target "BuildSample" <| fun _ -> sampleSln "Rebuild"
let libs = ["SolrNet"; "SolrNet.DSL"; "HttpWebAdapters"; "Castle.Facilities.SolrNetIntegration"; "Ninject.Integration.SolrNet"; "NHibernate.SolrNet"; "StructureMap.SolrNetIntegration"; "AutofacContrib.SolrNet"; "Unity.SolrNetIntegration"]
let dlls = [for l in libs -> l + ".dll"]
let dirs = [for l in libs -> l @@ "bin" @@ config]
let testAssemblies = !! ("**/bin/"+config+"/*Tests.dll") |> Seq.distinctBy (fun p -> p.Split [|'/';'\\'|] |> System.Linq.Enumerable.Last)
let noIntegrationTests = "exclude Category: Integration"
let onlyIntegrationTests = "Category: Integration"
let testTargets = List.map (fun lib -> "Test." + lib) libs
for lib,target in List.zip libs testTargets do
Target target <| fun _ ->
!! (lib+".Tests/bin/"+config+"/"+lib+".Tests.dll")
|> Gallio.Run (fun p -> { p with Filters = noIntegrationTests })
Target "Coverage" <| fun _ ->
testAssemblies |> Gallio.Run (fun p -> { p with
Filters = noIntegrationTests
RunnerType = "NCover"
PluginDirectories = ["lib"] })
Target "IntegrationTest" <| fun _ ->
use s = Solr.start()
testAssemblies |> Gallio.Run (fun p -> { p with Filters = onlyIntegrationTests })
let merge libraries =
rm_rf buildDir
mkdir buildDir
let main = "SolrNet\\bin" @@ config @@ "SolrNet.dll"
let output = buildDir @@ dlls.[0]
let snk = if File.Exists keyFile then keyFile else null
ILMerge (fun p -> { p with
ToolPath = "lib\\ilmerge.exe"
Libraries = libraries
SearchDirectories = dirs
Internalize = InternalizeExcept "ilmerge.exclude"
KeyFile = snk
XmlDocs = true
}) output main
Target "Merge" <| fun _ ->
dlls |> Seq.skip 1 |> merge
Target "BasicMerge" <| fun _ ->
dlls |> Seq.skip 1 |> Seq.take 2 |> merge
Target "Version" <| fun _ ->
for l in libs do
AssemblyInfo <| fun p -> { p with
OutputFileName = l @@ "Properties\\AssemblyInfo.cs"
CLSCompliant = Some true
AssemblyTitle = l
AssemblyDescription = l
AssemblyProduct = l
AssemblyInformationalVersion = Git.sha1()
AssemblyCopyright = "Copyright Mauricio Scheffer 2007-" + DateTime.Now.Year.ToString()
Guid = "6688f9b4-5f2d-4fd6-aafc-3a81c84a69f1"
AssemblyVersion = version
AssemblyFileVersion = version }
Target "Docs" <| fun _ ->
rm_rf docsDir
let r = Shell.Exec(@"tools\doxygen\doxygen.exe")
if r <> 0 then failwith "Doxygen failed"
rm docsFile
Rename docsFile (docsDir @@ "html\\index.chm")
rm_rf docsDir
Target "NuGet" <| fun _ ->
rm_rf nugetDir
mkdir nugetDocs
mkdir nugetLib
cp docsFile nugetDocs
!!(buildDir @@ "SolrNet.*") |> Copy nugetLib
nuGetBuild "SolrNet" "Apache Solr client" ["CommonServiceLocator", "[1.0]"]
let nuGetSingle dir =
rm_rf nugetDir
mkdir nugetLib
!!(dir @@ "bin" @@ config @@ (dir + ".*")) |> Copy nugetLib
nuGetBuild
let solrNetDep = "SolrNet", "[" + version + "]"
Target "NuGet.Windsor" <| fun _ ->
nuGetSingle
"Castle.Facilities.SolrNetIntegration"
"SolrNet.Windsor"
"Windsor facility for SolrNet"
["Castle.Windsor", "[3.0.0.4001]"; solrNetDep]
Target "NuGet.Ninject" <| fun _ ->
nuGetSingle
"Ninject.Integration.SolrNet"
"SolrNet.Ninject"
"Ninject module for SolrNet"
["Ninject", "[2.2.0.0,2.2.1.0]"; solrNetDep]
Target "NuGet.NHibernate" <| fun _ ->
nuGetSingle
"NHibernate.SolrNet"
"SolrNet.NHibernate"
"NHibernate integration for SolrNet"
["NHibernate", "[3.2.0.4000]"; solrNetDep]
Target "NuGet.StructureMap" <| fun _ ->
nuGetSingle
"StructureMap.SolrNetIntegration"
"SolrNet.StructureMap"
"StructureMap registry for SolrNet"
["structuremap", "[2.6.2.0]"; solrNetDep]
Target "NuGet.Autofac" <| fun _ ->
nuGetSingle
"AutofacContrib.SolrNet"
"SolrNet.Autofac"
"Autofac module for SolrNet"
["Autofac", "[2.5.2.830]"; solrNetDep]
Target "NuGet.Unity" <| fun _ ->
nuGetSingle
"Unity.SolrNetIntegration"
"SolrNet.Unity"
"Unity integration for SolrNet"
["Unity", "[2.1.505.0]"; solrNetDep]
Target "ReleasePackage" <| fun _ ->
let outputPath = "build"
rm_rf outputPath
mkdir outputPath
cp "readme.txt" outputPath
if File.Exists docsFile then
cp docsFile outputPath
!+ (buildDir @@ "SolrNet.*")
++ "license.txt" ++ "lib\\Microsoft.Practices.ServiceLocation.*"
|> Scan
|> Copy outputPath
let unmerged = outputPath @@ "unmerged"
mkdir unmerged
for l in libs do
!! (l @@ "bin" @@ config @@ (l + ".*"))
|> Copy unmerged
run "BasicMerge"
cp (buildDir @@ "SolrNet.dll") unmerged
!! (unmerged @@ "SolrNet.DSL.*") |> DeleteFiles
!! (unmerged @@ "HttpWebAdapters.*") |> DeleteFiles
let zipFile = "SolrNet-"+version+".zip"
rm zipFile
!! (outputPath @@ "**\\*") |> Zip outputPath zipFile
rm_rf outputPath
Target "PackageSampleApp" <| fun _ ->
let outputSolr = buildDir @@ solr
cp_r solr outputSolr
rm_rf (outputSolr @@ "solr\\data")
let logs = outputSolr @@ "logs"
rm_rf logs
mkdir logs
cp_r "tools\\Cassini" (buildDir @@ "tools\\Cassini")
let sampleApp = "SampleSolrApp"
let outputSampleApp = buildDir @@ sampleApp
cp_r sampleApp outputSampleApp
rm_rf (outputSampleApp @@ "obj")
rm_rf (outputSampleApp @@ "log.txt")
rm_rf (outputSampleApp @@ "SampleSolrApp.sln.cache")
mkdir (outputSampleApp @@ "lib")
!+ (outputSampleApp @@ "bin\\*")
-- "**\\SampleSolrApp.*" -- "**\\SolrNet.*"
|> Scan
|> Copy (outputSampleApp @@ "lib")
["pingsolr.js"; "license.txt"; "runsample.bat"] |> Copy buildDir
let csproj = outputSampleApp @@ "SampleSolrApp.csproj"
let xml = XDocument.Load csproj
let refs = xml.Elements() .> "ItemGroup" .> "Reference" .> "HintPath"
refs
|> Seq.filter (startsWith @"..\lib")
|> Seq.iter (replaceValue @"..\" "")
refs
|> Seq.filter (contains "SolrNet.dll")
|> Seq.iter (setValue @"..\SolrNet.dll")
xml.Save csproj
!! (buildDir @@ "**\\*")
|> Zip buildDir ("SolrNet-"+version+"-sample.zip")
Target "BuildAll" DoNothing
Target "TestAndRelease" DoNothing
Target "BuildAndRelease" DoNothing
Target "NuGet.All" DoNothing
Target "All" DoNothing
Target "Test" DoNothing
"Test" <== ["BuildAll"] @ testTargets
"BuildAll" <== ["Build";"Merge";"BuildSample"]
"BuildAndRelease" <== ["Clean";"Version";"BuildAll";"Docs";"ReleasePackage"]
"TestAndRelease" <== ["Clean";"Version";"Test";"ReleasePackage"]
"NuGet" <== ["Clean";"Build";"BasicMerge";"Docs"]
"NuGet.All" <== (getAllTargetsNames() |> List.filter ((<*) "NuGet") |> List.filter ((<>) "NuGet.All") |> List.sort)
"All" <== ["BuildAndRelease";"PackageSampleApp";"NuGet.All"]
Run target