forked from alexeyzimarev/ReactiveUI.Autofac
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
129 lines (109 loc) · 3.34 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
126
127
128
129
// include Fake libs
#I "packages/FAKE/tools/"
#r "packages/FAKE/tools/FakeLib.dll"
#r "packages/FAKE/tools/Fake.Deploy.Lib.dll"
open Fake
open Fake.Paket
open Fake.FileUtils
open Fake.Testing.XUnit2
open Fake.PaketTemplate
open Fake.AssemblyInfoFile
open Fake.ProcessHelper
open Fake.FileHelper
open Fake.Json
let pathInfo = directoryInfo "."
let product = environVarOrDefault "productName" pathInfo.Name
let company = "Alexey Zimarev"
let copyright = "Copyright © " + System.DateTime.UtcNow.Year.ToString() + " " + company
// Directories
let rootDir = currentDirectory
let buildDir = currentDirectory + "/bin/"
let testsDir = currentDirectory + "/tests/"
let nugetDir = currentDirectory + "/nuget"
let testOutputDir = currentDirectory + "/"
let gitversion = environVarOrDefault "GitVersion" "gitversion.exe"
// Filesets
let appReferences =
!! "src/**/*.csproj"
++ "src/**/*.fsproj"
-- "src/**/*Tests.csproj"
let testReferences =
!! "src/**/*Tests.csproj"
type Version = {
Major: int
Minor: string
Patch: string
PreReleaseTag: string
PreReleaseTagWithDash: string
BuildMetaData: string
BuildMetaDataPadded: string
FullBuildMetaData: string
MajorMinorPatch: string
SemVer: string
LegacySemVer: string
LegacySemVerPadded: string
AssemblySemVer: string
FullSemVer: string
InformationalVersion: string
BranchName: string
Sha: string
NuGetVersionV2: string
NuGetVersion: string
CommitDate: string
}
let mutable gitVer = Unchecked.defaultof<Version>
// Targets
Target "Clean" (fun _ ->
CleanDirs [buildDir; testsDir; nugetDir ]
MSBuildRelease buildDir "Clean" appReferences
|> Log "Clean-Output: "
)
Target "SetVersion" (fun _ ->
let result = ExecProcessAndReturnMessages (fun info ->
info.FileName <- gitversion
info.WorkingDirectory <- "."
info.Arguments <- "/output json") (System.TimeSpan.FromMinutes 5.0)
if result.ExitCode <> 0 then failwithf "'GitVersion.exe' returned with a non-zero exit code"
let jsonResult = System.String.Concat(result.Messages)
jsonResult |> deserialize<Version> |> fun ver -> gitVer <- ver
CreateCSharpAssemblyInfo "./src/SolutionAssemblyInfo.cs"
[Attribute.Product product
Attribute.Company company
Attribute.Copyright copyright
Attribute.Version gitVer.AssemblySemVer
Attribute.FileVersion (gitVer.MajorMinorPatch + ".0")
Attribute.InformationalVersion gitVer.InformationalVersion]
)
Target "BuildApp" (fun _ ->
MSBuildRelease buildDir "Build" appReferences
|> Log "BuildApp-Output: "
)
Target "BuildTests" (fun _ ->
MSBuildRelease testsDir "Build" testReferences
|> Log "BuildTests-Output: "
)
Target "Pack" (fun _ ->
Pack (fun p ->
{p with
OutputPath = nugetDir
WorkingDir = rootDir + "/src"
Version = gitVer.NuGetVersionV2
})
)
Target "Test" (fun _ ->
!! (testsDir @@ "/*.Tests.dll")
|> xUnit2 (fun p ->
{ p with
NUnitXmlOutputPath = Some (testOutputDir + "testresults.xml");
ToolPath = @"packages/xunit.runner.console/tools/xunit.console.exe"
})
)
// Build order
"Clean"
==> "SetVersion"
==> "BuildApp"
==> "BuildTests"
==> "Test"
==> "Pack"
// start build
RunTargetOrDefault "Pack"