Repository navigation
Expand file tree
/
Copy pathbuild-service.fsx
More file actions
164 lines (120 loc) · 4.53 KB
/
Copy pathbuild-service.fsx
File metadata and controls
164 lines (120 loc) · 4.53 KB
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
//http://fsharp.github.io/FAKE/apidocs/fake-filehelper.html
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll" // include Fake lib
#r "System.Xml.Linq"
#r "packages/ConfigJson/lib/ConfigJsonNET.dll"
open System
open System.IO
open Fake.TaskRunnerHelper
open Fake
open Fake.FileUtils
open System.Xml.Linq
open System.Collections.Generic
open Fake.Testing
let buildParam = getBuildParamOrDefault "buildType" "release"
// Directories
let root="./.build/build-"+buildParam+"-service"
let buildDir = root+"/app/"
let testDir =root+ "/test"
let deployDir = root+"/deploy/"
let nugetWorkingDir =root+ "/packaging/"
let allPackageFiles = [(buildDir+"InventoryService.Messages.dll")]
let nugetDeployPath = getBuildParamOrDefault "nugetDeployPath" deployDir
//let testOutput = FullName (root+ "-TestResults")
let testOutput = FullName "./.build/TestResults"
//--------------------------------------------------------------------------------
// Information about the project for Nuget and Assembly info files
//--------------------------------------------------------------------------------
let product = "InventoryService"
let authors = [ "Officialcomminity" ]
let copyright = "Copyright © Officialcomminity 2016"
let company = "Officialcomminity"
let description = "Prototyping some things for real-time inventory service"
let tags = ["InventoryService";"occ";]
let projectName="InventoryService.Messages"
// Read release notes and version
let BuildFn<'T>= match buildParam with
| "debug" -> MSBuildDebug
| _ ->MSBuildRelease
let BuildVersionType= match buildParam with
| "release" -> ""
| _ -> "-"+buildParam
let NugetDeployPath= match nugetDeployPath with
| "release" -> ""
| _ -> "-"+buildParam
// version info
let version =
match buildServer with
| TeamCity -> (buildVersion+BuildVersionType)
| _ -> ("1.0.6"+BuildVersionType)
// Targets
Target "Clean" (fun _ ->
CleanDirs [root]
CreateDir deployDir
CreateDir testDir
CreateDir buildDir
CreateDir nugetWorkingDir
CreateDir testOutput
)
let serviceReferences = !! "./InventoryService.ServiceDeployment/**/*.csproj"
Target "BuildService" (fun _ ->
MSBuildDebug buildDir "Build" serviceReferences
|> Log "AppBuild-Output: "
)
let appReferences = !! "./InventoryService.Messages/**/*.csproj"
let testReferences = !! "./InventoryService.Tests/*.csproj"
Target "BuildMessages" (fun _ ->
BuildFn buildDir "Build" appReferences
|> Log "AppBuild-Output: "
)
Target "BuildTest" (fun _ ->
BuildFn testDir "Build" testReferences
|> Log "TestBuild-Output: "
)
Target "xUnitTest" (fun _ ->
let xunitTestAssemblies = !! (testDir + "/InventoryService.Tests.dll")
let xunitToolPath = findToolInSubPath "xunit.console.exe" "packages/FAKE/xunit.runner.console/tools"
printfn "Using XUnit runner: %s" xunitToolPath
let runSingleAssembly assembly =
let assemblyName = Path.GetFileNameWithoutExtension(assembly)
xUnit2
(fun p -> { p with XmlOutputPath = Some (testOutput + @"\" + assemblyName + "_xunit_"+buildParam+".xml"); HtmlOutputPath = Some (testOutput + @"\" + assemblyName + "_xunit_"+buildParam+".HTML"); ToolPath = xunitToolPath; TimeOut = System.TimeSpan.FromMinutes 30.0; Parallel = ParallelMode.NoParallelization })
(Seq.singleton assembly)
xunitTestAssemblies |> Seq.iter (runSingleAssembly)
)
Target "CreateNuget" (fun _ ->
// Copy all the package files into a package folder
CopyFiles nugetWorkingDir allPackageFiles
NuGet (fun p ->
{
p with
Authors = authors
Project = projectName
Description = description
OutputPath = deployDir
Summary = description
WorkingDir = nugetWorkingDir
Version = version
})
"InventoryService.Messages.nuspec"
)
Target "Deploy" (fun _ ->
!! (buildDir + "/**/*.*")
-- "*.zip"
|> Zip buildDir (deployDir + "InventoryService." + version + ".zip")
)
Target "RemotePublishNuGet" (fun _ ->
!! (deployDir + "*.nupkg")
|> Copy NugetDeployPath
)
// Build order
"Clean"
==> "BuildMessages"
==> "BuildTest"
==> "xUnitTest"
==> "BuildService"
==> "CreateNuget"
==> "RemotePublishNuGet"
==> "Deploy"
// start build
RunTargetOrDefault "Deploy"