forked from fsprojects/Paket
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
714 lines (570 loc) · 23.9 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
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
System.IO.Directory.SetCurrentDirectory __SOURCE_DIRECTORY__
#r @"packages/build/FAKE/tools/FakeLib.dll"
#r "System.IO.Compression.FileSystem"
open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open Fake.UserInputHelper
open System
open System.IO
open Fake.Testing.NUnit3
open System.Security.Cryptography
// --------------------------------------------------------------------------------------
// START TODO: Provide project-specific details below
// --------------------------------------------------------------------------------------
// Information about the project are used
// - for version and project name in generated AssemblyInfo file
// - by the generated NuGet package
// - to run tests and to publish documentation on GitHub gh-pages
// - for documentation, you also need to edit info in "docs/tools/generate.fsx"
// The name of the project
// (used by attributes in AssemblyInfo, name of a NuGet package and directory in 'src')
let project = "Paket"
// Short summary of the project
// (used as description in AssemblyInfo and as a short summary for NuGet package)
let summary = "A dependency manager for .NET with support for NuGet packages and git repositories."
// Longer description of the project
// (used as a description for NuGet package; line breaks are automatically cleaned up)
let description = "A dependency manager for .NET with support for NuGet packages and git repositories."
// List of author names (for NuGet package)
let authors = [ "Paket team" ]
// Tags for your project (for NuGet package)
let tags = "nuget, bundler, F#"
// File system information
let solutionFile = "Paket.sln"
// Pattern specifying assemblies to be tested using NUnit
let testAssemblies = "tests/**/bin/Release/*Tests*.dll"
let integrationTestAssemblies = "integrationtests/Paket.IntegrationTests/bin/Release/*Tests*.dll"
// Git configuration (used for publishing documentation in gh-pages branch)
// The profile where the project is posted
let gitOwner = "fsprojects"
let gitHome = "https://github.com/" + gitOwner
// The name of the project on GitHub
let gitName = "Paket"
// The url for the raw files hosted
let gitRaw = environVarOrDefault "gitRaw" "https://raw.github.com/fsprojects"
let dotnetcliVersion = DotNetCli.GetDotNetSDKVersionFromGlobalJson()
let mutable dotnetExePath = "dotnet"
// --------------------------------------------------------------------------------------
// END TODO: The rest of the file includes standard build steps
// --------------------------------------------------------------------------------------
let buildDir = "bin"
let buildDirNetCore = "bin_netcore"
let tempDir = "temp"
let buildMergedDir = buildDir @@ "merged"
let paketFile = buildMergedDir @@ "paket.exe"
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
System.Net.ServicePointManager.SecurityProtocol <- unbox 192 ||| unbox 768 ||| unbox 3072 ||| unbox 48
// Read additional information from the release notes document
let releaseNotesData =
File.ReadAllLines "RELEASE_NOTES.md"
|> parseAllReleaseNotes
let release = List.head releaseNotesData
let stable =
match releaseNotesData |> List.tryFind (fun r -> r.NugetVersion.Contains("-") |> not) with
| Some stable -> stable
| _ -> release
let testSuiteFilterFlakyTests = getEnvironmentVarAsBoolOrDefault "PAKET_TESTSUITE_FLAKYTESTS" false
let genFSAssemblyInfo (projectPath) =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
let folderName = System.IO.Path.GetFileName(System.IO.Path.GetDirectoryName(projectPath))
let basePath = "src" @@ folderName
let fileName = basePath @@ "AssemblyInfo.fs"
CreateFSharpAssemblyInfo fileName
[ Attribute.Title (projectName)
Attribute.Product project
Attribute.Company (authors |> String.concat ", ")
Attribute.Description summary
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion
Attribute.InformationalVersion release.NugetVersion ]
let genCSAssemblyInfo (projectPath) =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
let folderName = System.IO.Path.GetDirectoryName(projectPath)
let basePath = folderName @@ "Properties"
let fileName = basePath @@ "AssemblyInfo.cs"
CreateCSharpAssemblyInfo fileName
[ Attribute.Title (projectName)
Attribute.Product project
Attribute.Description summary
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion
Attribute.InformationalVersion release.NugetVersion ]
// Generate assembly info files with the right version & up-to-date information
Target "AssemblyInfo" (fun _ ->
let fsProjs = !! "src/**/*.fsproj" |> Seq.filter (fun s -> not <| s.Contains("preview"))
let csProjs = !! "src/**/*.csproj" |> Seq.filter (fun s -> not <| s.Contains("preview"))
fsProjs |> Seq.iter genFSAssemblyInfo
csProjs |> Seq.iter genCSAssemblyInfo
)
Target "InstallDotNetCore" (fun _ ->
dotnetExePath <- DotNetCli.InstallDotNetSDK dotnetcliVersion
Environment.SetEnvironmentVariable("DOTNET_EXE_PATH", dotnetExePath)
)
// --------------------------------------------------------------------------------------
// Clean build results
Target "Clean" (fun _ ->
!! "src/**/bin"
++ "tests/**/bin"
++ buildDir
++ buildDirNetCore
++ tempDir
|> CleanDirs
!! "**/obj/**/*.nuspec"
|> DeleteFiles
)
Target "CleanDocs" (fun _ ->
CleanDirs ["docs/output"]
)
// --------------------------------------------------------------------------------------
// Build library & test project
Target "Build" (fun _ ->
if isMono then
!! solutionFile
|> MSBuildReleaseExt "" [
"VisualStudioVersion", "14.0"
"ToolsVersion" , "14.0"
] "Rebuild"
|> ignore
else
!! solutionFile
|> MSBuildReleaseExt "" [
"VisualStudioVersion", "14.0"
"ToolsVersion" , "14.0"
"SourceLinkCreate" , "true"
] "Rebuild"
|> ignore
)
let assertExitCodeZero x =
if x = 0 then () else
failwithf "Command failed with exit code %i" x
let runCmdIn workDir exe =
Printf.ksprintf (fun args ->
tracefn "%s %s" exe args
Shell.Exec(exe, args, workDir) |> assertExitCodeZero)
/// Execute a dotnet cli command
let dotnet workDir = runCmdIn workDir "dotnet"
Target "DotnetRestoreTools" (fun _ ->
DotNetCli.Restore (fun c ->
{ c with
Project = currentDirectory </> "tools" </> "tools.fsproj"
ToolPath = dotnetExePath
})
)
Target "DotnetRestore" (fun _ ->
//WORKAROUND dotnet restore with paket doesnt restore the PackageReference of SourceLink
// ref https://github.com/fsprojects/Paket/issues/2930
Paket.Restore (fun p ->
{ p with
Group = "NetCoreTools" })
DotNetCli.Restore (fun c ->
{ c with
Project = "Paket.preview3.sln"
ToolPath = dotnetExePath
})
)
Target "DotnetBuild" (fun _ ->
DotNetCli.Build (fun c ->
{ c with
Project = "Paket.preview3.sln"
ToolPath = dotnetExePath
AdditionalArgs = [ "/p:SourceLinkCreate=true" ]
})
)
"Clean" ==> "DotnetRestore" ==> "DotnetBuild"
Target "DotnetPublish" (fun _ ->
DotNetCli.Publish (fun c ->
{ c with
Project = "src/Paket.preview3"
ToolPath = dotnetExePath
Output = FullName (currentDirectory </> buildDirNetCore)
})
)
"Clean" ==> "DotnetBuild" ?=> "DotnetPublish"
Target "DotnetPackage" (fun _ ->
let outPath = FullName (currentDirectory </> tempDir </> "dotnetcore")
CleanDir outPath
DotNetCli.Pack (fun c ->
{ c with
Project = "src/Paket.Core.preview3/Paket.Core.fsproj"
ToolPath = dotnetExePath
AdditionalArgs = [(sprintf "-o \"%s\"" outPath); (sprintf "/p:Version=%s" release.NugetVersion)]
})
)
Target "DotnetTest" (fun _ ->
CreateDir "tests_result/netcore/Paket.Tests"
DotNetCli.Test (fun c ->
{ c with
Project = "tests/Paket.Tests.preview3/Paket.Tests.fsproj"
AdditionalArgs =
[ "--filter"; (if testSuiteFilterFlakyTests then "TestCategory=Flaky" else "TestCategory!=Flaky")
sprintf "--logger:trx;LogFileName=%s" ("tests_result/netcore/Paket.Tests/TestResult.trx" |> Path.GetFullPath) ]
ToolPath = dotnetExePath
})
)
Target "RunIntegrationTestsNetCore" (fun _ ->
CreateDir "tests_result/netcore/Paket.IntegrationTests"
// improves the speed of the test-suite by disabling the runtime resolution.
System.Environment.SetEnvironmentVariable("PAKET_DISABLE_RUNTIME_RESOLUTION", "true")
DotNetCli.Test (fun c ->
{ c with
Project = "integrationtests/Paket.IntegrationTests.preview3/Paket.IntegrationTests.fsproj"
ToolPath = dotnetExePath
AdditionalArgs =
[ "--filter"; (if testSuiteFilterFlakyTests then "TestCategory=Flaky" else "TestCategory!=Flaky")
sprintf "--logger:trx;LogFileName=%s" ("tests_result/netcore/Paket.IntegrationTests/TestResult.trx" |> Path.GetFullPath) ]
TimeOut = TimeSpan.FromMinutes 50.
})
)
"Clean" ==> "DotnetPublish" ==> "RunIntegrationTestsNetCore"
// --------------------------------------------------------------------------------------
// Run the unit tests using test runner
Target "RunTests" (fun _ ->
CreateDir "tests_result/net/Paket.Tests"
!! testAssemblies
|> NUnit3 (fun p ->
{ p with
ShadowCopy = false
WorkingDir = "tests_result/net/Paket.Tests" |> Path.GetFullPath
Agents = Some 1 //workaround for https://github.com/nunit/nunit-console/issues/219
TimeOut = TimeSpan.FromMinutes 20. })
)
Target "QuickTest" (fun _ ->
[ "src/Paket.Core/Paket.Core.fsproj"
"tests/Paket.Tests/Paket.Tests.fsproj"
] |> MSBuildRelease "" "Rebuild"
|> ignore
!! testAssemblies
|> NUnit3 (fun p ->
{ p with
ShadowCopy = false
WorkingDir = "tests/Paket.Tests" |> Path.GetFullPath
TimeOut = TimeSpan.FromMinutes 20. })
)
"Clean" ==> "QuickTest"
Target "QuickIntegrationTests" (fun _ ->
[ "src/Paket.Core/Paket.Core.fsproj"
"src/Paket/Paket.fsproj"
"integrationtests/Paket.IntegrationTests/Paket.IntegrationTests.fsproj"
] |> MSBuildDebug "" "Rebuild"
|> ignore
!! integrationTestAssemblies
|> NUnit3 (fun p ->
{ p with
ShadowCopy = false
Where = "cat==scriptgen"
WorkingDir = "integrationtests/Paket.IntegrationTests" |> Path.GetFullPath
TimeOut = TimeSpan.FromMinutes 40. })
)
"Clean" ==> "QuickIntegrationTests"
// --------------------------------------------------------------------------------------
// Build a NuGet package
let mergeLibs = ["paket.exe"; "Paket.Core.dll"; "FSharp.Core.dll"; "Newtonsoft.Json.dll"; "Argu.dll"; "Chessie.dll"; "Mono.Cecil.dll"]
Target "MergePaketTool" (fun _ ->
CreateDir buildMergedDir
let toPack =
mergeLibs
|> List.map (fun l -> buildDir @@ l)
|> separated " "
let result =
ExecProcess (fun info ->
info.FileName <- currentDirectory </> "packages" </> "build" </> "ILRepack" </> "tools" </> "ILRepack.exe"
info.Arguments <- sprintf "/lib:%s /ver:%s /out:%s %s" buildDir release.AssemblyVersion paketFile toPack
) (TimeSpan.FromMinutes 5.)
if result <> 0 then failwithf "Error during ILRepack execution."
)
Target "RunIntegrationTests" (fun _ ->
CreateDir "tests_result/net/Paket.IntegrationTests"
// improves the speed of the test-suite by disabling the runtime resolution.
System.Environment.SetEnvironmentVariable("PAKET_DISABLE_RUNTIME_RESOLUTION", "true")
!! integrationTestAssemblies
|> NUnit3 (fun p ->
{ p with
ShadowCopy = false
WorkingDir = "tests_result/net/Paket.IntegrationTests" |> Path.GetFullPath
Where = if testSuiteFilterFlakyTests then "cat==Flaky" else "cat!=Flaky"
TimeOut = TimeSpan.FromMinutes 40. })
)
"Clean" ==> "Build" ==> "RunIntegrationTests"
let pfx = "code-sign.pfx"
let mutable isUnsignedAllowed = true
Target "EnsurePackageSigned" (fun _ -> isUnsignedAllowed <- false)
Target "SignAssemblies" (fun _ ->
if not <| fileExists pfx then
if isUnsignedAllowed then ()
else failwithf "%s not found, can't sign assemblies" pfx
else
let filesToSign =
!! "bin/**/*.exe"
++ "bin/**/Paket.Core.dll"
filesToSign
|> Seq.iter (fun executable ->
let signtool = currentDirectory @@ "tools" @@ "SignTool" @@ "signtool.exe"
let args = sprintf "sign /f %s /t http://timestamp.comodoca.com/authenticode %s" pfx executable
let result =
ExecProcess (fun info ->
info.FileName <- signtool
info.Arguments <- args) System.TimeSpan.MaxValue
if result <> 0 then failwithf "Error during signing %s with %s" executable pfx)
)
Target "CalculateDownloadHash" (fun _ ->
use stream = File.OpenRead(paketFile)
use sha = new SHA256Managed()
let checksum = sha.ComputeHash(stream)
let hash = BitConverter.ToString(checksum).Replace("-", String.Empty)
File.WriteAllText(buildMergedDir @@ "paket-sha256.txt", sprintf "%s paket.exe" hash)
)
Target "NuGet" (fun _ ->
let testTemplateFiles =
!! "integrationtests/**/paket.template"
|> Seq.map (fun f -> f, f + "-disabled")
|> Seq.toList
try
testTemplateFiles
|> Seq.iter (fun (f, d) -> File.Move(f, d))
let files = !! "src/**/*.preview*" |> Seq.toList
for file in files do
File.Move(file,file + ".temp")
Paket.Pack (fun p ->
{ p with
ToolPath = "bin/merged/paket.exe"
Version = release.NugetVersion
ReleaseNotes = toLines release.Notes })
for file in files do
File.Move(file + ".temp",file)
finally
testTemplateFiles
|> Seq.iter (fun (f, d) ->
if File.Exists(d) then File.Move(d, f))
)
"DotnetPublish" ==> "NuGet"
Target "MergeDotnetCoreIntoNuget" (fun _ ->
let nupkg = tempDir </> sprintf "Paket.Core.%s.nupkg" (release.NugetVersion) |> Path.GetFullPath
let netcoreNupkg = tempDir </> "dotnetcore" </> sprintf "Paket.Core.%s.nupkg" (release.NugetVersion) |> Path.GetFullPath
let runTool = runCmdIn "tools" dotnetExePath
runTool """mergenupkg --source "%s" --other "%s" --framework netstandard2.0 """ nupkg netcoreNupkg
)
Target "PublishNuGet" (fun _ ->
if hasBuildParam "PublishBootstrapper" |> not then
!! (tempDir </> "*bootstrapper*")
|> Seq.iter File.Delete
!! (tempDir </> "dotnetcore" </> "*.nupkg")
|> Seq.iter File.Delete
Paket.Push (fun p ->
{ p with
ToolPath = "bin/merged/paket.exe"
WorkingDir = tempDir })
)
// --------------------------------------------------------------------------------------
// Generate the documentation
let disableDocs = false // https://github.com/fsprojects/FSharp.Formatting/issues/461
let fakePath = __SOURCE_DIRECTORY__ @@ "packages" @@ "build" @@ "FAKE" @@ "tools" @@ "FAKE.exe"
let fakeStartInfo fsiargs script workingDirectory args environmentVars =
(fun (info: System.Diagnostics.ProcessStartInfo) ->
info.FileName <- fakePath
info.Arguments <- sprintf "%s --fsiargs %s -d:FAKE \"%s\"" args fsiargs script
info.WorkingDirectory <- workingDirectory
let setVar k v =
info.EnvironmentVariables.[k] <- v
for (k, v) in environmentVars do
setVar k v
setVar "MSBuild" msBuildExe
setVar "GIT" Git.CommandHelper.gitPath
setVar "FSI" fsiPath)
/// Run the given startinfo by printing the output (live)
let executeWithOutput configStartInfo =
let exitCode =
ExecProcessWithLambdas
configStartInfo
TimeSpan.MaxValue false ignore ignore
System.Threading.Thread.Sleep 1000
exitCode
/// Run the given startinfo by redirecting the output (live)
let executeWithRedirect errorF messageF configStartInfo =
let exitCode =
ExecProcessWithLambdas
configStartInfo
TimeSpan.MaxValue true errorF messageF
System.Threading.Thread.Sleep 1000
exitCode
/// Helper to fail when the exitcode is <> 0
let executeHelper executer fail traceMsg failMessage configStartInfo =
trace traceMsg
let exit = executer configStartInfo
if exit <> 0 then
if fail then
failwith failMessage
else
traceImportant failMessage
else
traceImportant "Succeeded"
()
let execute = executeHelper executeWithOutput
Target "GenerateReferenceDocs" (fun _ ->
if disableDocs then () else
let args = ["--define:RELEASE"; "--define:REFERENCE"]
let argLine = System.String.Join(" ", args)
execute
true
(sprintf "Building reference documentation, this could take some time, please wait...")
"generating reference documentation failed"
(fakeStartInfo argLine "generate.fsx" "docs/tools" "" [])
)
let generateHelp' commands fail debug =
// remove FSharp.Compiler.Service.MSBuild.v12.dll
// otherwise FCS thinks it should use msbuild, which leads to insanity
!! "packages/**/FSharp.Compiler.Service.MSBuild.*.dll"
|> DeleteFiles
let args =
[ if not debug then yield "--define:RELEASE"
if commands then yield "--define:COMMANDS"
yield "--define:HELP"]
let argLine = System.String.Join(" ", args)
execute
fail
(sprintf "Building documentation (%A), this could take some time, please wait..." commands)
"generating documentation failed"
(fakeStartInfo argLine "generate.fsx" "docs/tools" "" [])
CleanDir "docs/output/commands"
let generateHelp commands fail =
generateHelp' commands fail false
Target "GenerateHelp" (fun _ ->
if disableDocs then () else
DeleteFile "docs/content/release-notes.md"
CopyFile "docs/content/" "RELEASE_NOTES.md"
Rename "docs/content/release-notes.md" "docs/content/RELEASE_NOTES.md"
DeleteFile "docs/content/license.md"
CopyFile "docs/content/" "LICENSE.txt"
Rename "docs/content/license.md" "docs/content/LICENSE.txt"
generateHelp true true
)
Target "GenerateHelpDebug" (fun _ ->
if disableDocs then () else
DeleteFile "docs/content/release-notes.md"
CopyFile "docs/content/" "RELEASE_NOTES.md"
Rename "docs/content/release-notes.md" "docs/content/RELEASE_NOTES.md"
DeleteFile "docs/content/license.md"
CopyFile "docs/content/" "LICENSE.txt"
Rename "docs/content/license.md" "docs/content/LICENSE.txt"
generateHelp' true true true
)
Target "KeepRunning" (fun _ ->
use watcher = !! "docs/content/**/*.*" |> WatchChanges (fun changes ->
generateHelp false false
)
traceImportant "Waiting for help edits. Press any key to stop."
System.Console.ReadKey() |> ignore
watcher.Dispose()
)
Target "GenerateDocs" DoNothing
// --------------------------------------------------------------------------------------
// Release Scripts
Target "ReleaseDocs" (fun _ ->
if disableDocs then () else
let tempDocsDir = "temp/gh-pages"
CleanDir tempDocsDir
Repository.cloneSingleBranch "" (gitHome + "/" + gitName + ".git") "gh-pages" tempDocsDir
Git.CommandHelper.runSimpleGitCommand tempDocsDir "rm . -f -r" |> ignore
CopyRecursive "docs/output" tempDocsDir true |> tracefn "%A"
File.WriteAllText("temp/gh-pages/latest",sprintf "https://github.com/fsprojects/Paket/releases/download/%s/paket.exe" release.NugetVersion)
File.WriteAllText("temp/gh-pages/stable",sprintf "https://github.com/fsprojects/Paket/releases/download/%s/paket.exe" stable.NugetVersion)
StageAll tempDocsDir
Git.Commit.Commit tempDocsDir (sprintf "Update generated documentation for version %s" release.NugetVersion)
Branches.push tempDocsDir
)
#load "paket-files/build/fsharp/FAKE/modules/Octokit/Octokit.fsx"
open Octokit
Target "ReleaseGitHub" (fun _ ->
let user =
match getBuildParam "github_user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ ->
eprintfn "Please update your release script to set 'github_user'!"
match getBuildParam "github-user" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserInput "Username: "
let pw =
match getBuildParam "github_password" with
| s when not (String.IsNullOrWhiteSpace s) -> s
| _ ->
eprintfn "Please update your release script to set 'github_password'!"
match getBuildParam "github_pw", getBuildParam "github-pw" with
| s, _ | _, s when not (String.IsNullOrWhiteSpace s) -> s
| _ -> getUserPassword "Password: "
let remote =
Git.CommandHelper.getGitResult "" "remote -v"
|> Seq.filter (fun (s: string) -> s.EndsWith("(push)"))
|> Seq.tryFind (fun (s: string) -> s.Contains(gitOwner + "/" + gitName))
|> function None -> gitHome + "/" + gitName | Some (s: string) -> s.Split().[0]
StageAll ""
Git.Commit.Commit "" (sprintf "Bump version to %s" release.NugetVersion)
Branches.pushBranch "" remote (Information.getBranchName "")
Branches.tag "" release.NugetVersion
Branches.pushTag "" remote release.NugetVersion
// release on github
createClient user pw
|> createDraft gitOwner gitName release.NugetVersion (release.SemVer.PreRelease <> None) release.Notes
|> uploadFile "./bin/merged/paket.exe"
|> uploadFile "./bin/merged/paket-sha256.txt"
|> uploadFile "./bin/paket.bootstrapper.exe"
|> uploadFile ".paket/paket.targets"
|> uploadFile ".paket/Paket.Restore.targets"
|> releaseDraft
|> Async.RunSynchronously
)
Target "Release" DoNothing
Target "BuildPackage" DoNothing
Target "BuildCore" DoNothing
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
Target "All" DoNothing
"Clean"
=?> ("InstallDotNetCore", not <| hasBuildParam "DISABLE_NETCORE")
=?> ("DotnetRestore", not <| hasBuildParam "DISABLE_NETCORE")
=?> ("DotnetBuild", not <| hasBuildParam "DISABLE_NETCORE")
==> "BuildCore"
"Clean"
==> "AssemblyInfo"
==> "Build"
<=> "BuildCore"
==> "RunTests"
=?> ("DotnetTest", not <| hasBuildParam "DISABLE_NETCORE")
=?> ("GenerateReferenceDocs",isLocalBuild && not isMono && not (hasBuildParam "SkipDocs"))
=?> ("GenerateDocs",isLocalBuild && not isMono && not (hasBuildParam "SkipDocs"))
==> "All"
=?> ("ReleaseDocs",isLocalBuild && not isMono && not (hasBuildParam "SkipDocs"))
"All"
==> "MergePaketTool"
=?> ("RunIntegrationTests", not <| (hasBuildParam "SkipIntegrationTests" || hasBuildParam "SkipIntegrationTestsNet"))
=?> ("RunIntegrationTestsNetCore", not <| (hasBuildParam "SkipIntegrationTests" || hasBuildParam "SkipIntegrationTestsNetCore" || hasBuildParam "DISABLE_NETCORE"))
==> "SignAssemblies"
==> "CalculateDownloadHash"
=?> ("NuGet", not <| hasBuildParam "SkipNuGet")
=?> ("DotnetPackage", not <| hasBuildParam "DISABLE_NETCORE" && not <| hasBuildParam "SkipNuGet")
=?> ("MergeDotnetCoreIntoNuget", not <| hasBuildParam "DISABLE_NETCORE" && not <| hasBuildParam "SkipNuGet")
==> "BuildPackage"
"EnsurePackageSigned"
?=> "SignAssemblies"
"CleanDocs"
==> "GenerateHelp"
==> "GenerateReferenceDocs"
==> "GenerateDocs"
"CleanDocs"
==> "GenerateHelpDebug"
"GenerateHelp"
==> "KeepRunning"
"BuildPackage"
==> "PublishNuGet"
"PublishNuGet"
==> "ReleaseGitHub"
==> "Release"
"ReleaseGitHub"
?=> "ReleaseDocs"
"ReleaseDocs"
==> "Release"
"EnsurePackageSigned"
==> "Release"
"DotnetRestoreTools"
==> "MergeDotnetCoreIntoNuget"
RunTargetOrDefault "All"