@@ -7,56 +7,65 @@ open System.Text
7
7
8
8
open Fake
9
9
open Fake.DotNetCli
10
+ open Fake.DocFxHelper
11
+ open Fake.NuGet .Install
10
12
11
- //--------------------------------------------------------------------------------
12
- // Information about the project for Nuget and Assembly info files
13
- //--------------------------------------------------------------------------------
14
-
15
- let product = " Akka.NET"
16
- let authors = [ " Akka.NET Team" ]
17
- let copyright = " Copyright © 2013-2015 Akka.NET Team"
18
- let company = " Akka.NET Team"
19
- let description = " Akka.NET is a port of the popular Java/Scala framework Akka to .NET"
20
- let tags = [ " akka" ; " actors" ; " actor" ; " model" ; " Akka" ; " concurrency" ]
13
+ // Variables
21
14
let configuration = " Release"
15
+ let solution = System.IO.Path.GetFullPath( string " ./src/Akka.Persistence.PostgreSql.sln" )
22
16
23
- //--------------------------------------------------------------------------------
24
17
// Directories
25
- //--------------------------------------------------------------------------------
26
-
27
- let slnFile = __ SOURCE_ DIRECTORY__ @@ " src/Akka.Persistence.PostgreSql.sln"
18
+ let toolsDir = __ SOURCE_ DIRECTORY__ @@ " tools"
28
19
let output = __ SOURCE_ DIRECTORY__ @@ " bin"
29
- let outputTests = output @@ " TestResults"
30
- let outputPerfTests = output @@ " perf "
20
+ let outputTests = __ SOURCE _ DIRECTORY __ @@ " TestResults"
21
+ let outputPerfTests = __ SOURCE _ DIRECTORY __ @@ " PerfResults "
31
22
let outputBinaries = output @@ " binaries"
32
23
let outputNuGet = output @@ " nuget"
33
- let outputBinariesNet45 = outputBinaries @@ " net45 "
34
- let outputBinariesNetStandard = outputBinaries @@ " netstandard1.6 "
24
+ let outputBinariesNet47 = outputBinaries @@ " net471 "
25
+ let outputBinariesNetStandard = outputBinaries @@ " netstandard2.0 "
35
26
36
27
// Read release notes and version
37
28
let buildNumber = environVarOrDefault " BUILD_NUMBER" " 0"
38
- let preReleaseVersionSuffix = ( if ( not ( buildNumber = " 0" )) then ( buildNumber) else " " ) + " -beta"
39
- let versionSuffix =
40
- match ( getBuildParam " nugetprerelease" ) with
41
- | " dev" -> preReleaseVersionSuffix
42
- | _ -> " "
29
+ let preReleaseVersionSuffix = " beta" + ( if ( not ( buildNumber = " 0" )) then ( buildNumber) else DateTime.UtcNow.Ticks.ToString())
43
30
44
31
let releaseNotes =
45
- File.ReadLines " ./ RELEASE_NOTES.md"
32
+ File.ReadLines (__ SOURCE _ DIRECTORY __ @@ " RELEASE_NOTES.md" )
46
33
|> ReleaseNotesHelper.parseReleaseNotes
47
34
35
+ let versionFromReleaseNotes =
36
+ match releaseNotes.SemVer.PreRelease with
37
+ | Some r -> r.Origin
38
+ | None -> " "
39
+
40
+ let versionSuffix =
41
+ match ( getBuildParam " nugetprerelease" ) with
42
+ | " dev" -> preReleaseVersionSuffix
43
+ | " " -> versionFromReleaseNotes
44
+ | str -> str
45
+
46
+ // Configuration values for tests
47
+ let testNetFrameworkVersion = " net471"
48
+ let testNetCoreVersion = " netcoreapp3.1"
49
+ let testNetVersion = " net5.0"
50
+
48
51
printfn " Assembly version: %s \n Nuget version; %s \n " releaseNotes.AssemblyVersion releaseNotes.NugetVersion
49
52
50
53
//--------------------------------------------------------------------------------
51
54
// Clean build results
52
55
//--------------------------------------------------------------------------------
53
56
54
57
Target " Clean" ( fun _ ->
58
+ ActivateFinalTarget " KillCreatedProcesses"
59
+
55
60
CleanDir output
56
61
CleanDir outputTests
57
62
CleanDir outputPerfTests
63
+ CleanDir outputBinaries
58
64
CleanDir outputNuGet
65
+ CleanDir outputBinariesNet47
66
+ CleanDir outputBinariesNetStandard
59
67
CleanDir " docs/_site"
68
+
60
69
CleanDirs !! " ./**/bin"
61
70
CleanDirs !! " ./**/obj"
62
71
)
@@ -69,8 +78,8 @@ Target "RestorePackages" (fun _ ->
69
78
DotNetCli.Restore
70
79
( fun p ->
71
80
{ p with
72
- Project = slnFile
73
- NoCache = false })
81
+ Project = solution
82
+ NoCache = true })
74
83
)
75
84
76
85
//--------------------------------------------------------------------------------
@@ -106,6 +115,22 @@ Target "Build" (fun _ ->
106
115
// Run tests
107
116
//--------------------------------------------------------------------------------
108
117
118
+ type Runtime =
119
+ | NetCore
120
+ | Net
121
+ | NetFramework
122
+
123
+ let getTestAssembly runtime project =
124
+ let assemblyPath = match runtime with
125
+ | NetCore -> !! ( " src" @@ " **" @@ " bin" @@ " Release" @@ testNetCoreVersion @@ fileNameWithoutExt project + " .dll" )
126
+ | NetFramework -> !! ( " src" @@ " **" @@ " bin" @@ " Release" @@ testNetFrameworkVersion @@ fileNameWithoutExt project + " .dll" )
127
+ | Net -> !! ( " src" @@ " **" @@ " bin" @@ " Release" @@ testNetVersion @@ fileNameWithoutExt project + " .dll" )
128
+
129
+ if Seq.isEmpty assemblyPath then
130
+ None
131
+ else
132
+ Some ( assemblyPath |> Seq.head)
133
+
109
134
module internal ResultHandling =
110
135
let (| OK | Failure |) = function
111
136
| 0 -> OK
@@ -125,62 +150,55 @@ module internal ResultHandling =
125
150
>> Option.iter ( failBuildWithMessage errorLevel)
126
151
127
152
Target " RunTests" <| fun _ ->
128
- let projects =
129
- match ( isWindows) with
130
- | true -> !! " ./src/**/*.Tests.csproj "
131
- | _ -> !! " ./src/**/*.Tests.csproj " // if you need to filter specs for Linux vs. Windows, do it here
153
+ let projects =
154
+ match ( isWindows) with
155
+ | true -> !! " ./src/**/*.Tests.*sproj "
156
+ | _ -> !! " ./src/**/*.Tests.*sproj " // if you need to filter specs for Linux vs. Windows, do it here
132
157
133
158
ensureDirectory outputTests
134
159
135
160
let runSingleProject project =
161
+ let arguments =
162
+ ( sprintf " test -c Release --no-build --logger:trx --logger:\" console;verbosity=normal\" --framework %s --results-directory \" %s \" -- -parallel none" testNetFrameworkVersion outputTests)
163
+
136
164
let result = ExecProcess( fun info ->
137
165
info.FileName <- " dotnet"
138
166
info.WorkingDirectory <- ( Directory.GetParent project) .FullName
139
- info.Arguments <- ( sprintf " xunit -f net452 -c Release -parallel none -teamcity -xml %s _net452_xunit.xml" ( outputTests @@ fileNameWithoutExt project))) ( TimeSpan.FromMinutes 30. )
140
-
141
- ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.DontFailBuild result
167
+ info.Arguments <- arguments) ( TimeSpan.FromMinutes 30.0 )
142
168
143
- // dotnet process will be killed by ExecProcess (or throw if can't) '
144
- // but per https://github.com/xunit/xunit/issues/1338 xunit.console may not
145
- killProcess " xunit.console"
146
- killProcess " dotnet"
169
+ ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
147
170
148
- projects |> Seq.iter ( log )
171
+ CreateDir outputTests
149
172
projects |> Seq.iter ( runSingleProject)
150
173
151
174
Target " RunTestsNetCore" <| fun _ ->
152
- let projects =
153
- match ( isWindows) with
154
- | true -> !! " ./src/**/*.Tests.csproj "
155
- | _ -> !! " ./src/**/*.Tests.csproj " // if you need to filter specs for Linux vs. Windows, do it here
175
+ let projects =
176
+ match ( isWindows) with
177
+ | true -> !! " ./src/**/*.Tests.*sproj "
178
+ | _ -> !! " ./src/**/*.Tests.*sproj " // if you need to filter specs for Linux vs. Windows, do it here
156
179
157
180
ensureDirectory outputTests
158
181
159
182
let runSingleProject project =
183
+ let arguments =
184
+ ( sprintf " test -c Release --no-build --logger:trx --logger:\" console;verbosity=normal\" --framework %s --results-directory \" %s \" -- -parallel none" testNetCoreVersion outputTests)
185
+
160
186
let result = ExecProcess( fun info ->
161
187
info.FileName <- " dotnet"
162
188
info.WorkingDirectory <- ( Directory.GetParent project) .FullName
163
- info.Arguments <- ( sprintf " xunit -f netcoreapp1.1 -c Release -parallel none -teamcity -xml %s _netcore_xunit.xml" ( outputTests @@ fileNameWithoutExt project))) ( TimeSpan.FromMinutes 30. )
164
-
165
- ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.DontFailBuild result
189
+ info.Arguments <- arguments) ( TimeSpan.FromMinutes 30.0 )
166
190
167
- // dotnet process will be killed by ExecProcess (or throw if can't) '
168
- // but per https://github.com/xunit/xunit/issues/1338 xunit.console may not
169
- killProcess " xunit.console"
170
- killProcess " dotnet"
191
+ ResultHandling.failBuildIfXUnitReportedError TestRunnerErrorLevel.Error result
171
192
172
- projects |> Seq.iter ( log )
193
+ CreateDir outputTests
173
194
projects |> Seq.iter ( runSingleProject)
174
195
175
196
//--------------------------------------------------------------------------------
176
197
// Nuget targets
177
198
//--------------------------------------------------------------------------------
178
199
179
- let overrideVersionSuffix ( project : string ) =
180
- match project with
181
- | _ -> versionSuffix // add additional matches to publish different versions for different projects in solution
182
-
183
200
Target " CreateNuget" ( fun _ ->
201
+ CreateDir outputNuGet // need this to stop Azure pipelines copy stage from error-ing out
184
202
let projects = !! " src/**/*.csproj"
185
203
-- " src/**/*Tests.csproj" // Don't publish unit tests
186
204
-- " src/**/*Tests*.csproj"
@@ -192,13 +210,14 @@ Target "CreateNuget" (fun _ ->
192
210
Project = project
193
211
Configuration = configuration
194
212
AdditionalArgs = [ " --include-symbols" ]
195
- VersionSuffix = overrideVersionSuffix project
196
- OutputPath = outputNuGet })
213
+ VersionSuffix = versionSuffix
214
+ OutputPath = " \" " + outputNuGet + " \" " })
197
215
198
216
projects |> Seq.iter ( runSingleProject)
199
217
)
200
218
201
219
Target " PublishNuget" ( fun _ ->
220
+
202
221
let projects = !! " ./bin/nuget/*.nupkg" -- " ./bin/nuget/*.symbols.nupkg"
203
222
let apiKey = getBuildParamOrDefault " nugetkey" " "
204
223
let source = getBuildParamOrDefault " nugetpublishurl" " "
@@ -225,6 +244,14 @@ Target "PublishNuget" (fun _ ->
225
244
projects |> Seq.iter ( runSingleProject)
226
245
)
227
246
247
+ FinalTarget " KillCreatedProcesses" ( fun _ ->
248
+ log " Shutting down dotnet build-server"
249
+ let result = ExecProcess( fun info ->
250
+ info.FileName <- " dotnet"
251
+ info.WorkingDirectory <- __ SOURCE_ DIRECTORY__
252
+ info.Arguments <- " build-server shutdown" ) ( System.TimeSpan.FromMinutes 2.0 )
253
+ if result <> 0 then failwithf " dotnet build-server shutdown failed"
254
+ )
228
255
229
256
//--------------------------------------------------------------------------------
230
257
// Help
@@ -328,22 +355,24 @@ Target "HelpDocs" <| fun _ ->
328
355
//--------------------------------------------------------------------------------
329
356
330
357
Target " BuildRelease" DoNothing
358
+ Target " All" DoNothing
331
359
Target " Nuget" DoNothing
332
360
333
361
// build dependencies
334
- " Clean" ==> " AssemblyInfo" ==> " RestorePackages" ==> " Build" ==> " BuildRelease"
362
+ " Clean" ==> " AssemblyInfo" ==> " RestorePackages" ==> " Build"
363
+ " Build" ==> " BuildRelease"
335
364
336
365
// test dependencies
337
- " RestorePackages " ==> " RunTests"
338
- " RestorePackages " ==> " RunTestsNetCore"
366
+ " Build " ==> " RunTests"
367
+ " Build " ==> " RunTestsNetCore"
339
368
340
369
// nuget dependencies
341
370
" BuildRelease" ==> " CreateNuget"
342
371
" CreateNuget" ==> " PublishNuget" ==> " Nuget"
343
372
344
- Target " All" DoNothing
345
373
" BuildRelease" ==> " All"
346
374
" RunTests" ==> " All"
375
+ " RunTestsNetCore" ==> " All"
347
376
" Nuget" ==> " All"
348
377
349
378
RunTargetOrDefault " Help"
0 commit comments