-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.fsx
144 lines (119 loc) · 4.84 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#r @"bin/FAKE/tools/FakeLib.dll"
open Fake
open Fake.Git
open Fake.AssemblyInfoFile
open Fake.ReleaseNotesHelper
open XUnit2Helper
open System
open System.IO
let solutionFile = "ConcurrencyUtilities.sln"
let assemblyInfoFile = ".\SharedAssemblyInfo.cs"
let sources = "./Src/ConcurrencyUtilities/"
let nuspec = sources + "ConcurrencyUtils.nuspec"
let sourcesNuspec = sources + "ConcurrencyUtils.Source.nuspec"
let nugetOutput = "./bin/NuGet"
let testAssemblies = "bin/Release/*Tests*.dll"
let release = LoadReleaseNotes "CHANGELOG.md"
Target "Clean" (fun _ ->
CleanDirs ["bin\Debug"; "bin\Release"; "packages"]
)
Target "RestoreNuget" <| fun _ -> RestorePackages()
// Generate assembly info files with the right version & up-to-date information
Target "AssemblyInfo" <| fun _ ->
CreateCSharpAssemblyInfo assemblyInfoFile
[Attribute.Company "Iulian Margarintescu"
Attribute.Copyright ("Copyright Iulian Margarintescu © " + DateTime.Now.Year.ToString())
Attribute.Product "Concurrency Utilities"
Attribute.Description "Utilities for performing efficient concurrent operations"
Attribute.Culture ""
Attribute.ComVisible false
Attribute.Version release.AssemblyVersion
Attribute.FileVersion release.AssemblyVersion]
let buildWithParams properties =
solutionFile
|> build (fun p ->
{ p with
Verbosity = Some(MSBuildVerbosity.Minimal)
Targets = ["Rebuild"]
Properties = properties
})
Target "BuildDebug" <| fun _ -> buildWithParams ["Configuration", "Debug"]
Target "Build" <| fun _ -> buildWithParams ["Configuration", "Release"]
let findXunit =
try
!!(@".\packages\xunit.runner.console.2.0.0*\tools\xunit.console.exe") |> Seq.exactlyOne
with
| _ ->
CleanDir "packages"
Run "RestoreNuget"
!!(@".\packages\xunit.runner.console.2.0.0*\tools\xunit.console.exe") |> Seq.exactlyOne
Target "RunTests" (fun _ ->
!! testAssemblies
|> xUnit2 (fun p ->
{ p with
ToolPath = findXunit
MaxThreads = 4
TimeOut = TimeSpan.FromMinutes 20.
Parallel = ParallelOption.Collections })
)
let processSourceFile content =
let header = File.ReadAllText "SourceHeader.cs"
replace "namespace ConcurrencyUtilities" "namespace $rootnamespace$.ConcurrencyUtilities" content
|> replace " public struct " "#if CONCURRENCY_UTILS_PUBLIC\r\npublic\r\n#else\r\ninternal\r\n#endif\r\n struct "
|> replace " public sealed class " "#if CONCURRENCY_UTILS_PUBLIC\r\npublic\r\n#else\r\ninternal\r\n#endif\r\n sealed class "
|> replace " public static class " "#if CONCURRENCY_UTILS_PUBLIC\r\npublic\r\n#else\r\ninternal\r\n#endif\r\n static class "
|> replace " public abstract class " "#if CONCURRENCY_UTILS_PUBLIC\r\npublic\r\n#else\r\ninternal\r\n#endif\r\n abstract class "
|> regex_replace "\s*(?:\: AtomicArray<.*>|\: AtomicValue<.*>|(?:\,|\:) ValueAdder<.*>|\: VolatileValue<.*>)" ""
|> regex_replace "(?<=\})\s*//\sRemoveAtPack(?+s:.*)//\sEndRemoveAtPack" ""
|> fun x -> header + x
Target "SourceNuGet" <| fun _ ->
let workDir = "./bin/Release/NuGet.Sources/"
ensureDirectory workDir
CleanDir workDir
ensureDirectory nugetOutput
for file in !! (sources + "*.cs") -- (sources + "Interfaces.cs") do
let name = Path.GetFileNameWithoutExtension file
let content = File.ReadAllText file
let processed = processSourceFile content
let output = Path.Combine(workDir, (name + ".cs.pp"))
File.WriteAllText(output, processed)
let files =
!!(workDir + "*.pp")
|> Seq.map (fun f -> f,Some (@"content\App_Packages\ConcurrencyUtils."+ release.NugetVersion + @"\" + (Path.GetFileName f)), None )
|> Seq.toList
NuGet (fun p ->
{p with
OutputPath = nugetOutput
WorkingDir = workDir
Version = release.NugetVersion
Dependencies = []
Files = files
Publish = false })
sourcesNuspec
Target "NuGet" <| fun _ ->
let workDir = "./bin/Release/NuGet/"
ensureDirectory workDir
CleanDir workDir
ensureDirectory nugetOutput
CleanDir nugetOutput
NuGet (fun p ->
{p with
OutputPath = nugetOutput
WorkingDir = workDir
Version = release.NugetVersion
Dependencies = []
Publish = false })
nuspec
Target "All" DoNothing
"Clean"
==> "RestoreNuget"
==> "AssemblyInfo"
==> "Build"
==> "RunTests"
==> "NuGet"
==> "SourceNuGet"
==> "All"
RunTargetOrDefault "All"