-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.fsx
84 lines (72 loc) · 2.21 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
// include Fake lib
#r "packages/FAKE/tools/FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open Fake.Git.Information
open Fake.ProcessHelper
open Fake.EnvironmentHelper
open System
open System.IO
// Properties
let buildDir = "bin/build"
let artifactsDir = "bin/artifacts"
let mergedExe = artifactsDir @@ "seafile-cli.exe"
let primaryExe = buildDir @@ "SeafileCli.exe"
let nugetPackages = "src/packages"
let sln = "src/SeafileCli.sln"
let solutionInfo = "src/SolutionInfo.cs"
let nugetExe = "packages/NuGet.CommandLine/tools/NuGet.exe"
let ilMergeExe = "packages/ILMerge/tools/net452/ILMerge.exe"
let name = "Seafile CLI"
let publisher = "Tobias Wallura"
let buildVersion =
match buildServer with
| LocalBuild -> "0"
| _ -> buildVersion
let gitVersion = getLastTag() |> SemVerHelper.parse
let makeVersion (semver: SemVerHelper.SemVerInfo) (buildVersion: string) =
sprintf "%d.%d.%d.%s" semver.Major semver.Minor semver.Patch buildVersion
let version = makeVersion (gitVersion) (buildVersion)
// Targets
Target "NugetRestore" (fun _ ->
sln
|> RestoreMSSolutionPackages (fun p ->
{ p with
OutputPath = nugetPackages
ToolPath = nugetExe })
)
Target "Clean" (fun _ ->
CleanDirs [buildDir; artifactsDir]
)
Target "Build" (fun _ ->
MSBuildDefaults <- { MSBuildDefaults with NodeReuse = false }
CreateCSharpAssemblyInfo solutionInfo [
Attribute.Version version
Attribute.FileVersion version
Attribute.InformationalVersion (version + " Build " + getCurrentSHA1("."))
Attribute.Company publisher
Attribute.Copyright ("Copyright (c) " + DateTime.Now.Year.ToString())
Attribute.Metadata("githash", getCurrentSHA1("."))
]
!! sln
|> MSBuildRelease buildDir "Build"
|> Log "Build-Output: "
)
Target "ILMerge" (fun _ ->
ILMerge (fun p ->
{ p with
ToolPath = ilMergeExe
TargetKind = Exe
AllowWildcards = true
Libraries = [buildDir @@ "*.dll"] })
mergedExe
primaryExe
)
Target "Default" DoNothing
// Dependencies
"Clean"
==> "Build"
==> "Default"
"Build" ==> "ILMerge"
"NugetRestore" ==> "Build"
RunTargetOrDefault "Default"