This repository was archived by the owner on Oct 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild.fsx
115 lines (92 loc) · 3.34 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
#r @"packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open System
open ReleaseNotesHelper
open Fake.FileSystemHelper
open Fake.Testing.XUnit2
let commitHash = Information.getCurrentSHA1 (".")
let release = LoadReleaseNotes "RELEASE_NOTES.md"
let description = "T4-like templating tool with support for F#"
let buildDir = "bin"
let mergeDir = "merge"
let nugetDir = "nuget"
let solution = "Templatus.sln"
Target "Clean" (fun _ ->
CleanDirs [ buildDir; mergeDir ]
!! (nugetDir @@ "*.nupkg")
|> DeleteFiles
)
Target "SetAssemblyInfo" (fun _ ->
let commonAttributes = [
Attribute.Product "Templatus"
Attribute.Description description
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion
Attribute.Metadata("githash", commitHash) ]
CreateFSharpAssemblyInfo (currentDirectory @@ "src" @@ "Templatus" @@ "AssemblyInfo.fs")
([ Attribute.Title "Templatus command line"
Attribute.Guid "1a2d4fdb-650e-48c5-abb8-a5348329811b" ] @ commonAttributes)
CreateFSharpAssemblyInfo (currentDirectory @@ "src" @@ "Templatus.Core" @@ "AssemblyInfo.fs")
([ Attribute.Title "Templatus lib"
Attribute.Guid "f4a3cb74-b623-4d17-a3d3-7861ca0513f8" ] @ commonAttributes)
)
Target "Build" (fun _ ->
!! solution
|> MSBuildRelease "" "Rebuild"
|> ignore
)
Target "Test" (fun _ ->
!! (buildDir @@ "*.Tests.dll")
|> xUnit2 (fun p -> { p with ToolPath = currentDirectory @@ "packages" @@ "xunit.runner.console" @@ "tools" @@ "net452" @@ "xunit.console.exe" })
)
Target "Merge" (fun _ ->
CreateDir mergeDir
let toPack =
[ "Templatus.exe"; "Templatus.Core.dll"; "Argu.dll"; "Chessie.dll"; "FSharp.Compiler.Service.dll"; "FParsec.dll"; "FParsecCS.dll"; ]
|> List.map (fun l -> buildDir @@ l)
|> separated " "
let result =
ExecProcess
(fun info -> info.FileName <- currentDirectory @@ "packages" @@ "ILRepack" @@ "tools" @@ "ILRepack.exe"
info.Arguments <- sprintf "/attr:\"%s\" /lib:%s /out:%s %s" (currentDirectory @@ "bin" @@ "Templatus.exe") buildDir (mergeDir @@ "Templatus.exe") toPack)
(TimeSpan.FromMinutes 5.)
[ "FSharp.Core.dll"; "FSharp.Core.optdata"; "FSharp.Core.sigdata" ]
|> List.map (fun l -> buildDir @@ l)
|> CopyFiles mergeDir
if result <> 0 then failwith "Error during ILRepack execution."
)
Target "Default" DoNothing
Target "CreateNuget" (fun _ ->
Paket.Pack (fun p ->
{ p with
Version = release.NugetVersion
ReleaseNotes = toLines release.Notes
OutputPath = nugetDir })
)
Target "PublishNuget" (fun _ ->
Paket.Push (fun p ->
{ p with
WorkingDir = nugetDir })
)
Target "Release" (fun _ ->
StageAll ""
Commit "" (sprintf "Release version %s" release.NugetVersion)
Branches.push ""
Branches.tag "" release.NugetVersion
Branches.pushTag "" "origin" release.NugetVersion
)
let releasing =
[ "CreateNuget"; "PublishNuget"; "Release" ]
|> List.exists (getBuildParam "target" |> (=))
"Clean"
=?> ("SetAssemblyInfo", releasing)
==> "Build"
//==> "Test"
==> "Merge"
==> "Default"
=?> ("CreateNuget", not isLinux)
=?> ("PublishNuget", not isLinux)
==> "Release"
RunTargetOrDefault "Default"