@@ -9,7 +9,6 @@ open Fake.DotNet
9
9
open Fake.IO
10
10
open Fake.IO .Globbing .Operators
11
11
open Fake.IO .FileSystemOperators
12
- open Fake.Tools
13
12
14
13
open ExtractDocs
15
14
@@ -42,111 +41,15 @@ module ExamplesToCode =
42
41
ConvertFile file targetDir
43
42
44
43
type BuildVersion = { assembly: string ; file: string ; info: string ; package: string }
45
- let getVersion () =
46
- // The --first-parent flag is needed to make our walk linear from current commit and top.
47
- // This way also merge commit is counted as "1".
48
- let desc = Git.CommandHelper.runSimpleGitCommand " " " describe --tags --long --abbrev=40 --first-parent --match=v*"
49
- let result = Regex.Match( desc,
50
- @" ^v(?<maj>\d+)\.(?<min>\d+)\.(?<rev>\d+)(?<pre>-\w+\d*)?-(?<num>\d+)-g(?<sha>[a-z0-9]+)$" ,
51
- RegexOptions.IgnoreCase)
52
- .Groups
53
- let getMatch ( name : string ) = result.[ name]. Value
54
-
55
- let ( major , minor , revision , preReleaseSuffix , commitsNum , commitSha ) =
56
- ( getMatch " maj" |> int, getMatch " min" |> int, getMatch " rev" |> int, getMatch " pre" , getMatch " num" |> int, getMatch " sha" )
57
-
58
- // Assembly version should contain major and minor only, as no breaking changes are expected in bug fix releases.
59
- let assemblyVersion = sprintf " %d .%d .0.0" major minor
60
- let fileVersion = sprintf " %d .%d .%d .%d " major minor revision commitsNum
61
-
62
- // If number of commits since last tag is greater than zero, we append another identifier with number of commits.
63
- // The produced version is larger than the last tag version.
64
- // If we are on a tag, we use version without modification.
65
- // Examples of output: 3.50.2.1, 3.50.2.215, 3.50.1-rc1.3, 3.50.1-rc3.35
66
- let packageVersion = match commitsNum with
67
- | 0 -> sprintf " %d .%d .%d%s " major minor revision preReleaseSuffix
68
- | _ -> sprintf " %d .%d .%d%s .%d " major minor revision preReleaseSuffix commitsNum
69
-
70
- let infoVersion = match commitsNum with
71
- | 0 -> packageVersion
72
- | _ -> sprintf " %s -%s " packageVersion commitSha
73
-
74
- { assembly = assemblyVersion; file = fileVersion; info = infoVersion; package = packageVersion }
75
-
44
+
76
45
let root = __ SOURCE_ DIRECTORY__ </> " .." |> Path.getFullName
77
46
78
47
let configuration = Environment.environVarOrDefault " configuration" " Debug"
79
- let version = getVersion ()
80
-
81
- let additionalArgs = [
82
- " AssemblyVersion" , version.assembly
83
- " FileVersion" , version.file
84
- " InformationalVersion" , version.info
85
- " PackageVersion" , version.package
86
- ]
87
48
88
49
let output = root </> " bin" </> configuration
89
50
let solution = ( root </> " NSubstitute.sln" )
90
51
91
52
let initTargets () =
92
- Target.create " Default" ignore
93
- Target.create " All" ignore
94
-
95
- Target.description( " Clean compilation artifacts and remove output bin directory" )
96
- Target.create " Clean" ( fun _ ->
97
- DotNet.exec ( fun p -> { p with WorkingDirectory = root }) " clean"
98
- ( sprintf " --configuration %s --verbosity minimal" configuration)
99
- |> ignore
100
- Shell.cleanDirs [ output ]
101
- )
102
-
103
- Target.description( " Restore dependencies" )
104
- Target.create " Restore" ( fun _ ->
105
- DotNet.restore ( fun p -> p) solution
106
- )
107
-
108
- Target.description( " Compile all projects" )
109
- Target.create " Build" ( fun _ ->
110
- DotNet.build ( fun p ->
111
- { p with Configuration = DotNet.BuildConfiguration.fromString configuration
112
- MSBuildParams = { p.MSBuildParams with Properties = additionalArgs }
113
- }) solution
114
- )
115
-
116
- Target.description( " Run tests" )
117
- Target.create " Test" ( fun _ ->
118
- DotNet.test ( fun p ->
119
- { p with Configuration = DotNet.BuildConfiguration.fromString configuration
120
- MSBuildParams = { p.MSBuildParams with Properties = additionalArgs }
121
- }) ( root </> " tests/NSubstitute.Acceptance.Specs/NSubstitute.Acceptance.Specs.csproj" )
122
- )
123
-
124
- Target.description( " Generate Nuget package" )
125
- Target.create " Package" ( fun _ ->
126
- DotNet.pack ( fun p ->
127
- { p with Configuration = DotNet.BuildConfiguration.fromString configuration
128
- MSBuildParams = { p.MSBuildParams with Properties = additionalArgs }
129
- }) ( root </> " src/NSubstitute/NSubstitute.csproj" )
130
- )
131
-
132
- Target.description( " Run all benchmarks. Must be run with configuration=Release." )
133
- Target.create " Benchmarks" ( fun _ ->
134
- if configuration <> " Release" then
135
- failwith " Benchmarks can only be run in Release mode. Please re-run the build in Release configuration."
136
-
137
- let benchmarkCsproj = root </> " tests/NSubstitute.Benchmarks/NSubstitute.Benchmarks.csproj" |> Path.getFullName
138
- let benchmarkToRun = Environment.environVarOrDefault " benchmark" " *" // Defaults to "*" (all)
139
- [ " netcoreapp2.1" ]
140
- |> List.iter ( fun framework ->
141
- Trace.traceImportant ( " Benchmarking " + framework)
142
- let work = output </> " benchmark-" + framework
143
- Directory.ensure work
144
- DotNet.exec ( fun p -> { p with WorkingDirectory = work }) " run"
145
- ( " --framework " + framework + " --project " + benchmarkCsproj + " -- " + benchmarkToRun)
146
- |> ignore
147
- )
148
- )
149
-
150
53
Target.description( " Extract, build and test code from documentation." )
151
54
Target.create " TestCodeFromDocs" <| fun _ ->
152
55
let outputCodePath = output </> " CodeFromDocs"
@@ -219,23 +122,7 @@ let initTargets() =
219
122
printfn " "
220
123
Target.listAvailable()
221
124
222
- " Clean" ?=> " Build" |> ignore
223
- " Clean" ?=> " Test" |> ignore
224
- " Clean" ?=> " Restore" |> ignore
225
- " Clean" ?=> " Documentation" |> ignore
226
- " Clean" ?=> " TestCodeFromDocs" |> ignore
227
- " Clean" ?=> " Package" |> ignore
228
- " Clean" ?=> " Default" |> ignore
229
-
230
- " Build" <== [ " Restore" ]
231
- " Test" <== [ " Build" ]
232
125
" Documentation" <== [ " TestCodeFromDocs" ]
233
- " Benchmarks" <== [ " Build" ]
234
- // For packaging, use a clean build and make sure all tests (inc. docs) pass.
235
- " Package" <== [ " Clean" ; " Build" ; " Test" ; " TestCodeFromDocs" ]
236
-
237
- " Default" <== [ " Restore" ; " Build" ; " Test" ]
238
- " All" <== [ " Clean" ; " Default" ; " Documentation" ; " Package" ]
239
126
240
127
[<EntryPoint>]
241
128
let main argv =
@@ -245,5 +132,5 @@ let main argv =
245
132
|> Context.RuntimeContext.Fake
246
133
|> Context.setExecutionContext
247
134
initTargets()
248
- Target.runOrDefaultWithArguments " Default "
135
+ Target.runOrDefaultWithArguments " TestCodeFromDocs "
249
136
0
0 commit comments