-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.fsx
125 lines (102 loc) · 3.46 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
#I @"Source\packages\Fake.1.64.10\tools"
#r "FakeLib.dll"
open Fake
(* properties *)
let authors = ["Max Malook"]
let projectName = "Contexteer"
let copyright = "Copyright - Contexteer 2012"
TraceEnvironmentVariables()
let version = if isLocalBuild then getBuildParamOrDefault "version" "0.0.0.1" else buildVersion
let packageVersion = getBuildParamOrDefault "packageVersion" version
let NugetKey = getBuildParamOrDefault "nuget.key" ""
(* Directories *)
let targetPlatformDir = getTargetPlatformDir "v4.0.30319"
let sourceDir = @".\Source\"
let packagesDir = sourceDir + @"packages\"
let buildDir = @".\Build\"
let testDir = buildDir
let testOutputDir = buildDir + @"Specs\"
let nugetDir = buildDir + @"NuGet\"
let deployDir = @".\Release\"
(* files *)
let slnReferences = !! (sourceDir + @"*.sln")
let nugetPath = sourceDir + @".nuget\NuGet.exe"
let nuspecPath = sourceDir + "Contexteer\Contexteer.nuspec"
(* tests *)
let MSpecVersion = lazy ( GetPackageVersion packagesDir "Machine.Specifications" )
let mspecTool = lazy( sprintf @"%s\Machine.Specifications.%s\tools\mspec-clr4.exe" packagesDir (MSpecVersion.Force()) )
(* Targets *)
Target "Clean" (fun _ ->
CleanDirs [buildDir; testDir; testOutputDir; nugetDir; deployDir]
)
Target "SetAssemblyInfo" (fun _ ->
AssemblyInfo
(fun p ->
{p with
CodeLanguage = CSharp;
AssemblyVersion = version;
AssemblyInformationalVersion = packageVersion;
AssemblyTitle = "Contexteer";
AssemblyDescription = "A framework for contexts";
AssemblyCompany = projectName;
AssemblyCopyright = copyright;
Guid = "fab4c86e-fa7a-453c-acb6-90e229411626";
OutputFileName = @".\Source\Contexteer\Properties\AssemblyInfo.cs"})
)
Target "BuildApp" (fun _ ->
MSBuildRelease buildDir "Build" slnReferences
|> Log "AppBuild-Output: "
)
Target "Test" (fun _ ->
ActivateFinalTarget "DeployTestResults"
!+ (testDir + "/*.Specs.dll")
++ (testDir + "/*.Examples.dll")
|> Scan
|> MSpec (fun p ->
{p with
ToolPath = mspecTool.Force()
HtmlOutputDir = testOutputDir})
)
FinalTarget "DeployTestResults" (fun () ->
!+ (testOutputDir + "\**\*.*")
|> Scan
|> Zip testOutputDir (sprintf "%sMSpecResults.zip" deployDir)
)
Target "BuildZip" (fun _ ->
!+ (buildDir + "/**/*.*")
-- "*.zip"
-- "**/*.Specs.dll"
-- "**/*.Specs.pdb"
|> Scan
|> Zip buildDir (deployDir @@ sprintf "%s-%s.zip" projectName version)
)
Target "BuildNuGet" (fun _ ->
let nugetLibDir = nugetDir @@ "lib" @@ "4.0"
CleanDirs [nugetLibDir]
[buildDir @@ "Contexteer.dll";
buildDir @@ "Contexteer.xml"]
|> CopyTo nugetLibDir
NuGet (fun p ->
{p with
ToolPath = nugetPath
Authors = authors
Project = projectName
Version = packageVersion
OutputPath = nugetDir
AccessKey = NugetKey
Publish = NugetKey <> "" })
nuspecPath
!! (nugetDir + "Contexteer.*.nupkg")
|> CopyTo deployDir
)
Target "Default" DoNothing
// Build order
"Clean"
==> "SetAssemblyInfo"
==> "BuildApp"
==> "Test"
==> "BuildZip"
==> "BuildNuGet"
==> "Default"
// start build
RunParameterTargetOrDefault "target" "Default"