This repository has been archived by the owner on Dec 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Build.fsx
107 lines (84 loc) · 3.53 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
#r "paket: groupref FakeBuild //"
#load "./.fake/build.fsx/intellisense.fsx"
open Fake.IO
open Fake.BuildServer
open Fake.IO.Globbing.Operators
open Fake.DotNet
open Fake.JavaScript
open Fake.Core
open Fake.Tools
BuildServer.install [
AppVeyor.Installer
]
let isAppveyor = AppVeyor.detect()
let gitVersion = GitVersion.generateProperties id
Target.create "Clean" (fun _ ->
["build" ; "reports" ; "src/common" ; "src/BCC.Web/node_modules"]
|> Shell.cleanDirs
let configuration =
(fun p -> { p with
Properties = ["Configuration", "Release"]
Verbosity = Some MSBuildVerbosity.Minimal })
!! "src/BCC.Web.sln"
|> MSBuild.run configuration null "Clean" list.Empty
|> Trace.logItems "Clean-Output: "
)
Target.create "Build" (fun _ ->
CreateProcess.fromRawWindowsCommandLine "gitversion" "/updateassemblyinfo src\common\SharedAssemblyInfo.cs /ensureassemblyinfo"
|> Proc.run
|> ignore
Npm.install (fun p -> {p with WorkingDirectory = "src/BCC.Web"})
let configuration = (fun p -> { p with
DoRestore = true
Verbosity = Some MSBuildVerbosity.Minimal })
!! "src/BCC.Web.sln"
|> MSBuild.runRelease configuration null "Build"
|> Trace.logItems "AppBuild-Output: "
)
Target.create "Test" (fun _ ->
List.allPairs ["BCC.Web.Tests"] ["netcoreapp2.1"]
|> Seq.iter (fun (proj, framework) ->
let projectPath = sprintf "src\\%s\\%s.csproj" proj proj
let reportFile = sprintf "%s-%s.results.trx" proj framework
let configuration: (DotNet.TestOptions -> DotNet.TestOptions)
= (fun t -> {t with
Configuration = DotNet.BuildConfiguration.Release
NoBuild = true
Framework = Some framework
Logger = Some (sprintf "trx;LogFileName=%s" reportFile)
ResultsDirectory = Some "../../reports"})
DotNet.test configuration projectPath
Trace.publish ImportData.BuildArtifact (sprintf "reports/%s" reportFile)
)
)
Target.create "Package" (fun _ ->
DotNet.publish (fun p -> {p with
Configuration = DotNet.BuildConfiguration.Release
OutputPath = Some "../../build"}) "src/BCC.Web"
)
Target.create "Coverage" (fun _ ->
List.allPairs ["BCC.Web.Tests"] ["netcoreapp2.1"]
|> Seq.iter (fun (proj, framework) ->
let dllPath = sprintf "src\\%s\\bin\\Release\\%s\\%s.dll" proj framework proj
let projectPath = sprintf "src\\%s\\%s.csproj" proj proj
let reportPath = sprintf "reports/%s-%s.coverage.xml" proj framework
sprintf "%s --target \"dotnet\" --targetargs \"test -c Release -f %s %s --no-build\" --format opencover --output \"./%s\""
dllPath framework projectPath reportPath
|> CreateProcess.fromRawWindowsCommandLine "coverlet"
|> Proc.run
|> ignore
Trace.publish ImportData.BuildArtifact reportPath
if isAppveyor then
CreateProcess.fromRawWindowsCommandLine "codecov" (sprintf "-f \"%s\"" reportPath)
|> Proc.run
|> ignore
)
)
Target.create "Default" (fun _ -> ())
open Fake.Core.TargetOperators
"Clean" ==> "Build"
"Build" ==> "Package" ==> "Default"
"Build" ==> "Test" ==> "Default"
"Build" ==> "Coverage" ==> "Default"
// start build
Target.runOrDefault "Default"