-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathbuild.fsx
89 lines (71 loc) · 2.32 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
#I @"Source/packages/FAKE/tools"
#r "FakeLib.dll"
open System
open Fake
open Fake.DotNetCli
open Fake.DotNet.NuGet.NuGet
(* properties *)
let projectName = "FeatureSwitcher"
let ReleaseCandidate = getBuildParamOrDefault "releaseCandidate" (System.DateTime.Now.ToString("yyyyMMddHHmmss"))
let NugetKey = getBuildParamOrDefault "nuget.key" ""
(* Directories *)
let sourceDir = "Source"
let buildDir = "Build"
let testDir = buildDir
let nugetDir = buildDir @@ "NuGet/"
let deployDir = "./Release/"
(* helper functions *)
let packageVersion() =
let projectAssembly = buildDir @@ (sprintf "%s.dll" projectName)
let assemblyName = System.Reflection.AssemblyName.GetAssemblyName(projectAssembly)
let version = assemblyName.Version.ToString(3)
if ReleaseCandidate = "false" then
version
else
sprintf "%s-rc%s" version ReleaseCandidate
(* Targets *)
Target "Clean" <| fun _ ->
CleanDirs [buildDir; testDir; nugetDir; deployDir]
Target "BuildApp" <| fun _ ->
DotNetCli.Restore (fun p ->
{ p with WorkingDir = sourceDir } )
DotNetCli.Build (fun p ->
{ p with
WorkingDir = sourceDir
Configuration = "Release"
Output = "../../" ^ buildDir } )
Target "Test" <| fun _ ->
!! "Source/**/*.Specs.csproj"
|> Seq.iter (fun proj ->
DotNetCli.Test <| fun p ->
{ p with
Configuration = "Release"
Project = proj } )
Target "BuildNuGet" <| fun _ ->
DotNetCli.Pack
(fun p ->
{ p with
Configuration = "Release"
OutputPath = "../../" ^ nugetDir
WorkingDir = sourceDir
AdditionalArgs=[String.Format("/p:PackageVersion={0}", packageVersion())] } )
!! (nugetDir @@ (sprintf "%s.*.nupkg" projectName))
|> CopyTo deployDir
if NugetKey <> ""
then
NuGetPublish (fun p ->
{ p with
Project = projectName
Version = packageVersion()
OutputPath = nugetDir
WorkingDir = nugetDir
AccessKey = NugetKey } )
Target "Default" DoNothing
// Build order
"Clean"
==> "BuildApp"
==> "Test"
==> "BuildNuGet"
==> "Default"
// start build
RunTargetOrDefault "Default"