-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathbuild.fsx
100 lines (78 loc) · 2.83 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
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#r @"packages/FAKE/tools/FakeLib.dll"
open System
open System.IO
open Fake
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
// The name of the project
let project = "Shed"
// Short summary of the project
let summary = "A .NET runtime inspector."
// List of author names (for NuGet package)
let authors = [ "Enkomio" ]
// Build dir
let buildDir = "./build"
// Package dir
let deployDir = "./deploy"
// Read additional information from the release notes document
let releaseNotesData =
let changelogFile = "RELEASE_NOTES.md"
File.ReadAllLines(changelogFile)
|> parseAllReleaseNotes
let releaseVersion = (List.head releaseNotesData)
trace("Build release: " + releaseVersion.AssemblyVersion)
let genFSAssemblyInfo (projectPath) =
let projectName = System.IO.Path.GetFileNameWithoutExtension(projectPath)
let folderName = System.IO.Path.GetDirectoryName(projectPath)
let fileName = folderName @@ "AssemblyInfo.fs"
Console.WriteLine(fileName)
CreateFSharpAssemblyInfo fileName
[ Attribute.Title (projectName)
Attribute.Product project
Attribute.Company (authors |> String.concat ", ")
Attribute.Description summary
Attribute.Version (releaseVersion.AssemblyVersion + ".*")
Attribute.FileVersion (releaseVersion.AssemblyVersion + ".*")
Attribute.InformationalVersion (releaseVersion.NugetVersion + ".*") ]
Target "Clean" (fun _ ->
CleanDir buildDir
ensureDirectory buildDir
CleanDir deployDir
ensureDirectory deployDir
)
Target "AssemblyInfo" (fun _ ->
let fsProjs = !! "*/**/*.fsproj"
fsProjs |> Seq.iter genFSAssemblyInfo
)
Target "Compile" (fun _ ->
let build(project: String, buildDir: String) =
trace("Compile: " + project)
let fileName = Path.GetFileNameWithoutExtension(project)
let buildAppDir = Path.Combine(buildDir, fileName)
ensureDirectory buildAppDir
MSBuildRelease buildAppDir "Build" [project] |> Log "Build Output: "
// build Shed
build(Path.Combine("Shed", "Shed.fsproj"), buildDir)
)
Target "Release" (fun _ ->
let forbidden = [".pdb"]
!! (buildDir + "/**/*.*")
|> Seq.filter(fun f ->
forbidden
|> List.contains (Path.GetExtension(f).ToLowerInvariant())
|> not
)
|> Zip buildDir (Path.Combine(deployDir, "Shed." + releaseVersion.AssemblyVersion + ".zip"))
)
// --------------------------------------------------------------------------------------
// Run all targets by default. Invoke 'build <Target>' to override
Target "All" DoNothing
"Clean"
==> "AssemblyInfo"
==> "Compile"
==> "Release"
==> "All"
RunTargetOrDefault "All"