This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 182
/
build.fsx
465 lines (391 loc) · 17.3 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
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
#I @"tools\FAKE\tools\"
#r @"tools\FAKE\tools\FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open Fake.Git
open Fake.Testing.XUnit2
open System.IO
open Fake.OpenCoverHelper
open Fake.ReportGeneratorHelper
open Fake.FileHelper
let projectName = "FakeXrmEasy"
//Directories
let buildDir = @".\build"
let FakeXrmEasyBuildDir = buildDir + @"\FakeXrmEasy"
let FakeXrmEasy2013BuildDir = buildDir + @"\FakeXrmEasy.2013"
let FakeXrmEasy2015BuildDir = buildDir + @"\FakeXrmEasy.2015"
let FakeXrmEasy2016BuildDir = buildDir + @"\FakeXrmEasy.2016"
let FakeXrmEasy365BuildDir = buildDir + @"\FakeXrmEasy.365"
let FakeXrmEasy9BuildDir = buildDir + @"\FakeXrmEasy.9"
let FakeXrmEasySharedBuildDir = buildDir + @"\FakeXrmEasy.Shared"
let testDir = @".\test"
let FakeXrmEasyTestsBuildDir = testDir + @"\FakeXrmEasy.Tests"
let FakeXrmEasyTests2013BuildDir = testDir + @"\FakeXrmEasy.Tests.2013"
let FakeXrmEasyTests2015BuildDir = testDir + @"\FakeXrmEasy.Tests.2015"
let FakeXrmEasyTests2016BuildDir = testDir + @"\FakeXrmEasy.Tests.2016"
let FakeXrmEasyTests365BuildDir = testDir + @"\FakeXrmEasy.Tests.365"
let FakeXrmEasyTests9BuildDir = testDir + @"\FakeXrmEasy.Tests.9"
let FakeXrmEasyTestsSharedBuildDir = testDir + @"\FakeXrmEasy.Tests.Shared"
let deployDir = @".\Publish"
let FakeXrmEasyDeployDir = deployDir + @"\FakeXrmEasy"
let FakeXrmEasy2013DeployDir = deployDir + @"\FakeXrmEasy.2013"
let FakeXrmEasy2015DeployDir = deployDir + @"\FakeXrmEasy.2015"
let FakeXrmEasy2016DeployDir = deployDir + @"\FakeXrmEasy.2016"
let FakeXrmEasy365DeployDir = deployDir + @"\FakeXrmEasy.365"
let FakeXrmEasy9DeployDir = deployDir + @"\FakeXrmEasy.9"
let FakeXrmEasySharedDeployDir = deployDir + @"\FakeXrmEasy.Shared"
let nugetDir = @".\nuget\"
let nugetDeployDir = @"[Enter_NuGet_Url]"
let packagesDir = @".\packages\"
let nuGetCommandLine = @".\tools\nuget\nuget410.exe"
let mutable previousVersion = "1.58.0"
let mutable version = "1.58.1" //Copy this into previousVersion before publishing packages...
let mutable build = buildVersion
let mutable nugetVersion = version
let mutable asmVersion = version
let mutable asmInfoVersion = version
let mutable setupVersion = ""
let mutable releaseNotes = "https://github.com/jordimontana82/fake-xrm-easy/compare/v" + previousVersion + "...v" + version
let gitbranch = Git.Information.getBranchName "."
let sha = Git.Information.getCurrentHash()
Target "Clean" (fun _ ->
CleanDirs [buildDir; deployDir]
)
Target "RestorePackages" (fun _ ->
RestorePackages()
)
Target "BuildVersions" (fun _ ->
let safeBuildNumber = if not isLocalBuild then build else "0"
asmVersion <- version + "." + safeBuildNumber
asmInfoVersion <- asmVersion + " - " + gitbranch + " - " + sha
nugetVersion <- version + "." + safeBuildNumber
setupVersion <- version + "." + safeBuildNumber
match gitbranch with
| "master" -> ()
| "develop" -> (nugetVersion <- nugetVersion + " - " + "beta")
| _ -> (nugetVersion <- nugetVersion + " - " + gitbranch)
SetBuildNumber nugetVersion
)
Target "AssemblyInfo" (fun _ ->
BulkReplaceAssemblyInfoVersions "." (fun f ->
{f with
AssemblyVersion = asmVersion
AssemblyFileVersion = asmVersion
AssemblyInformationalVersion = asmInfoVersion})
)
Target "BuildFakeXrmEasy" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY") ]
!! @"FakeXrmEasy\*.csproj"
|> MSBuild FakeXrmEasyBuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.2013" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_2013") ]
!! @"FakeXrmEasy.2013\*.csproj"
|> MSBuild FakeXrmEasy2013BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.2015" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_2015") ]
!! @"FakeXrmEasy.2015\*.csproj"
|> MSBuild FakeXrmEasy2015BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.2016" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_2016") ]
!! @"FakeXrmEasy.2016\*.csproj"
|> MSBuild FakeXrmEasy2016BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.365" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_365") ]
!! @"FakeXrmEasy.365\*.csproj"
|> MSBuild FakeXrmEasy365BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.9" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_9") ]
!! @"FakeXrmEasy.9\*.csproj"
|> MSBuild FakeXrmEasy9BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.Tests" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY") ]
!! @"FakeXrmEasy.Tests\*.csproj"
|> MSBuild FakeXrmEasyTestsBuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.Tests.2013" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_2013") ]
!! @"FakeXrmEasy.Tests.2013\*.csproj"
|> MSBuild FakeXrmEasyTests2013BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.Tests.2015" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_2015") ]
!! @"FakeXrmEasy.Tests.2015\*.csproj"
|> MSBuild FakeXrmEasyTests2015BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.Tests.2016" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_2016") ]
!! @"FakeXrmEasy.Tests.2016\*.csproj"
|> MSBuild FakeXrmEasyTests2016BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.Tests.365" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_365") ]
!! @"FakeXrmEasy.Tests.365\*.csproj"
|> MSBuild FakeXrmEasyTests365BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "BuildFakeXrmEasy.Tests.9" (fun _->
let properties =
[ ("DefineConstants", "FAKE_XRM_EASY_9") ]
!! @"FakeXrmEasy.Tests.9\*.csproj"
|> MSBuild FakeXrmEasyTests9BuildDir "Rebuild" (properties)
|> Log "Build - Output: "
)
Target "Test.2011" (fun _ ->
!! (testDir @@ "\FakeXrmEasy.Tests\FakeXrmEasy.Tests.dll")
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit.2011.html") })
)
Target "Test.2013" (fun _ ->
!! (testDir @@ "\FakeXrmEasy.Tests.2013\FakeXrmEasy.Tests.2013.dll")
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit.2013.html") })
)
Target "Test.2015" (fun _ ->
!! (testDir @@ "\FakeXrmEasy.Tests.2015\FakeXrmEasy.Tests.2015.dll")
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit.2015.html") })
)
Target "Test.2016" (fun _ ->
!! (testDir @@ "\FakeXrmEasy.Tests.2016\FakeXrmEasy.Tests.2016.dll")
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit.2016.html") })
)
Target "Test.365" (fun _ ->
!! (testDir @@ "\FakeXrmEasy.Tests.365\FakeXrmEasy.Tests.365.dll")
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit.365.html") })
)
Target "Test.9" (fun _ ->
!! (testDir @@ "\FakeXrmEasy.Tests.9\FakeXrmEasy.Tests.9.dll")
|> xUnit2 (fun p -> { p with HtmlOutputPath = Some (testDir @@ "xunit.9.html") })
)
Target "NuGet" (fun _ ->
CreateDir(nugetDir)
"FakeXrmEasy.2011.nuspec"
|> NuGet (fun p ->
{p with
Project = "FakeXrmEasy"
Version = version
NoPackageAnalysis = true
ToolPath = nuGetCommandLine
OutputPath = nugetDir
ReleaseNotes = releaseNotes
Publish = true })
"FakeXrmEasy.2013.nuspec"
|> NuGet (fun p ->
{p with
Project = "FakeXrmEasy.2013"
Version = version
NoPackageAnalysis = true
ToolPath = nuGetCommandLine
OutputPath = nugetDir
ReleaseNotes = releaseNotes
Publish = true })
"FakeXrmEasy.2015.nuspec"
|> NuGet (fun p ->
{p with
Project = "FakeXrmEasy.2015"
Version = version
NoPackageAnalysis = true
ToolPath = nuGetCommandLine
OutputPath = nugetDir
ReleaseNotes = releaseNotes
Publish = true })
"FakeXrmEasy.2016.nuspec"
|> NuGet (fun p ->
{p with
Project = "FakeXrmEasy.2016"
Version = version
NoPackageAnalysis = true
ToolPath = nuGetCommandLine
OutputPath = nugetDir
ReleaseNotes = releaseNotes
Publish = true })
"FakeXrmEasy.365.nuspec"
|> NuGet (fun p ->
{p with
Project = "FakeXrmEasy.365"
Version = version
NoPackageAnalysis = true
ToolPath = nuGetCommandLine
OutputPath = nugetDir
ReleaseNotes = releaseNotes
Publish = true })
"FakeXrmEasy.9.nuspec"
|> NuGet (fun p ->
{p with
Project = "FakeXrmEasy.9"
Version = version
NoPackageAnalysis = true
ToolPath = nuGetCommandLine
OutputPath = nugetDir
ReleaseNotes = releaseNotes
Publish = true })
)
Target "PublishNuGet" (fun _ ->
let nugetPublishDir = (deployDir + "nuget")
CreateDir nugetPublishDir
!! (nugetDir + "*.nupkg")
|> Copy nugetPublishDir
XCopy nugetPublishDir nugetDeployDir
)
Target "Publish" (fun _ ->
CreateDir deployDir
CreateDir FakeXrmEasyDeployDir
CreateDir FakeXrmEasy2013DeployDir
CreateDir FakeXrmEasy2015DeployDir
CreateDir FakeXrmEasy2016DeployDir
CreateDir FakeXrmEasy365DeployDir
CreateDir FakeXrmEasy9DeployDir
!! (FakeXrmEasyBuildDir @@ @"/**/*.* ")
-- " *.pdb"
|> CopyTo FakeXrmEasyDeployDir
!! (FakeXrmEasy2013BuildDir @@ @"/**/*.* ")
-- " *.pdb"
|> CopyTo FakeXrmEasy2013DeployDir
!! (FakeXrmEasy2015BuildDir @@ @"/**/*.* ")
-- " *.pdb"
|> CopyTo FakeXrmEasy2015DeployDir
!! (FakeXrmEasy2016BuildDir @@ @"/**/*.* ")
-- " *.pdb"
|> CopyTo FakeXrmEasy2016DeployDir
!! (FakeXrmEasy365BuildDir @@ @"/**/*.* ")
-- " *.pdb"
|> CopyTo FakeXrmEasy365DeployDir
!! (FakeXrmEasy9BuildDir @@ @"/**/*.* ")
-- " *.pdb"
|> CopyTo FakeXrmEasy9DeployDir
)
Target "CodeCoverage.2011" (fun _ ->
OpenCover (fun p -> { p with
TestRunnerExePath = "./packages/xunit.runner.console.2.2.0/tools/xunit.console.exe"
ExePath = "./packages/OpenCover.4.6.519/tools/OpenCover.Console"
Register = RegisterType.RegisterUser
WorkingDir = (testDir @@ "\FakeXrmEasy.Tests")
Filter = "+[FakeXrmEasy*]* -[*.Tests*]*"
Output = "../coverage.2011.xml"
}) "FakeXrmEasy.Tests.dll"
)
Target "CodeCoverage.2013" (fun _ ->
OpenCover (fun p -> { p with
TestRunnerExePath = "./packages/xunit.runner.console.2.2.0/tools/xunit.console.exe"
ExePath = "./packages/OpenCover.4.6.519/tools/OpenCover.Console"
Register = RegisterType.RegisterUser
WorkingDir = (testDir @@ "\FakeXrmEasy.Tests.2013")
Filter = "+[FakeXrmEasy*]* -[*.Tests*]*"
Output = "../coverage.2013.xml"
}) "FakeXrmEasy.Tests.2013.dll"
)
Target "CodeCoverage.2015" (fun _ ->
OpenCover (fun p -> { p with
TestRunnerExePath = "./packages/xunit.runner.console.2.2.0/tools/xunit.console.exe"
ExePath = "./packages/OpenCover.4.6.519/tools/OpenCover.Console"
Register = RegisterType.RegisterUser
WorkingDir = (testDir @@ "\FakeXrmEasy.Tests.2015")
Filter = "+[FakeXrmEasy*]* -[*.Tests*]*"
Output = "../coverage.2015.xml"
}) "FakeXrmEasy.Tests.2015.dll"
)
Target "CodeCoverage.2016" (fun _ ->
OpenCover (fun p -> { p with
TestRunnerExePath = "./packages/xunit.runner.console.2.2.0/tools/xunit.console.exe"
ExePath = "./packages/OpenCover.4.6.519/tools/OpenCover.Console"
Register = RegisterType.RegisterUser
WorkingDir = (testDir @@ "\FakeXrmEasy.Tests.2016")
Filter = "+[FakeXrmEasy*]* -[*.Tests*]*"
Output = "../coverage.2016.xml"
}) "FakeXrmEasy.Tests.2016.dll"
)
Target "CodeCoverage.365" (fun _ ->
OpenCover (fun p -> { p with
TestRunnerExePath = "./packages/xunit.runner.console.2.2.0/tools/xunit.console.exe"
ExePath = "./packages/OpenCover.4.6.519/tools/OpenCover.Console"
Register = RegisterType.RegisterUser
WorkingDir = (testDir @@ "\FakeXrmEasy.Tests.365")
Filter = "+[FakeXrmEasy*]* -[*.Tests*]*"
Output = "../coverage.365.xml"
}) "FakeXrmEasy.Tests.365.dll"
)
Target "CodeCoverage.9" (fun _ ->
OpenCover (fun p -> { p with
TestRunnerExePath = "./packages/xunit.runner.console.2.2.0/tools/xunit.console.exe"
ExePath = "./packages/OpenCover.4.6.519/tools/OpenCover.Console"
Register = RegisterType.RegisterUser
WorkingDir = (testDir @@ "\FakeXrmEasy.Tests.9")
Filter = "+[FakeXrmEasy*]* -[*.Tests*]*"
Output = "../coverage.9.xml"
}) "FakeXrmEasy.Tests.9.dll"
)
Target "ReportCodeCoverage" (fun _ ->
ReportGenerator (fun p -> { p with
ExePath = "./packages/ReportGenerator.2.4.5.0/tools/ReportGenerator"
WorkingDir = (testDir @@ "\FakeXrmEasy.Tests")
TargetDir = "../reports"
ReportTypes = [ReportGeneratorReportType.Html; ReportGeneratorReportType.Badges ]
}) [ "..\coverage.2011.xml"; "..\coverage.2013.xml"; "..\coverage.2015.xml"; "..\coverage.2016.xml"; "..\coverage.365.xml"; "..\coverage.9.xml" ]
)
Target "ReplaceVersion" (fun _ ->
RegexReplaceInFileWithEncoding previousVersion version System.Text.Encoding.UTF8 "./Install-scripts/365/Install.ps1"
RegexReplaceInFileWithEncoding previousVersion version System.Text.Encoding.UTF8 "./Install-scripts/2011/Install.ps1"
RegexReplaceInFileWithEncoding previousVersion version System.Text.Encoding.UTF8 "./Install-scripts/2013/Install.ps1"
RegexReplaceInFileWithEncoding previousVersion version System.Text.Encoding.UTF8 "./Install-scripts/2015/Install.ps1"
RegexReplaceInFileWithEncoding previousVersion version System.Text.Encoding.UTF8 "./Install-scripts/2016/Install.ps1"
RegexReplaceInFileWithEncoding previousVersion version System.Text.Encoding.UTF8 "./Install-scripts/9/Install.ps1"
RegexReplaceInFileWithEncoding previousVersion version System.Text.Encoding.UTF8 "README.md"
)
"Clean"
==> "RestorePackages"
==> "BuildVersions"
==> "AssemblyInfo"
==> "BuildFakeXrmEasy"
==> "BuildFakeXrmEasy.2013"
==> "BuildFakeXrmEasy.2015"
==> "BuildFakeXrmEasy.2016"
==> "BuildFakeXrmEasy.365"
==> "BuildFakeXrmEasy.9"
==> "BuildFakeXrmEasy.Tests"
==> "BuildFakeXrmEasy.Tests.2013"
==> "BuildFakeXrmEasy.Tests.2015"
==> "BuildFakeXrmEasy.Tests.2016"
==> "BuildFakeXrmEasy.Tests.365"
==> "BuildFakeXrmEasy.Tests.9"
==> "Test.2011"
==> "Test.2013"
==> "Test.2015"
==> "Test.2016"
==> "Test.365"
==> "Test.9"
==> "CodeCoverage.2011"
==> "CodeCoverage.2013"
==> "CodeCoverage.2015"
==> "CodeCoverage.2016"
==> "CodeCoverage.365"
==> "CodeCoverage.9"
==> "ReportCodeCoverage"
==> "ReplaceVersion"
==> "Publish"
==> "NuGet"
==> "PublishNuGet"
RunTargetOrDefault "NuGet"