-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathsetup.fsx
174 lines (145 loc) · 4.75 KB
/
setup.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
#r "paket:
nuget BlackFox.VsWhere >= 1.0.0
nuget Fake.Core.Target >= 5.20.3
nuget Fake.Core.Environment >= 5.20.3
nuget Fake.Core.Process >= 5.20.3
nuget Fake.DotNet.Cli >= 5.20.3
nuget Fake.DotNet.NuGet >= 5.20.3
nuget Fake.IO.FileSystem >= 5.20.3 //"
#r "System.Xml"
#r "System.Xml.Linq"
open System
open System.IO
open System.Xml.Linq
open Fake.Core
open Fake.Core.TargetOperators
open Fake.DotNet
open Fake.DotNet.NuGet.Restore
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
let consoleBefore =
(Console.ForegroundColor, Console.BackgroundColor)
Shell.copyFile "./AltCover.Engine/Abstract.fsi" "./AltCover.Engine/Abstract.fs"
// Really bootstrap
let dotnetPath =
"dotnet" |> ProcessUtils.tryFindFileOnPath
let dotnetOptions (o: DotNet.Options) =
match dotnetPath with
| Some f -> { o with DotNetCliPath = f }
| None -> o
DotNet.restore
(fun o ->
{ o with
Packages = [ "./packages" ]
Common = dotnetOptions o.Common })
"./Build/NuGet.csproj"
let toolPackages =
let xml =
"./Build/NuGet.csproj"
|> Path.getFullName
|> XDocument.Load
xml.Descendants(XName.Get("PackageReference"))
|> Seq.map (fun x -> (x.Attribute(XName.Get("Include")).Value, x.Attribute(XName.Get("version")).Value))
|> Map.ofSeq
let packageVersion (p: string) =
p.ToLowerInvariant() + "/" + (toolPackages.Item p)
let nuget =
("./packages/"
+ (packageVersion "NuGet.CommandLine")
+ "/tools/NuGet.exe")
|> Path.getFullName
let dixon =
("./packages/"
+ (packageVersion "AltCode.Dixon")
+ "/Rules")
|> Path.getFullName
let fxcop =
if Environment.isWindows then
BlackFox.VsWhere.VsInstances.getAll ()
|> Seq.filter (fun i -> System.Version(i.InstallationVersion).Major = 16)
|> Seq.map
(fun i ->
i.InstallationPath
@@ "Team Tools/Static Analysis Tools/FxCop")
|> Seq.filter Directory.Exists
|> Seq.tryHead
else
None
let restore (o: RestorePackageParams) = { o with ToolPath = nuget }
let build = """// generated by dotnet fake run .\Build\setup.fsx
// includes by source all of AltCoverFake.DotNet.Testing.AltCover
#r "paket:
nuget Fake.Core.Target >= 5.20.3
nuget Fake.Core.Environment >= 5.20.3
nuget Fake.Core.Process >= 5.20.3
nuget Fake.DotNet.AssemblyInfoFile >= 5.20.3
nuget Fake.DotNet.Cli >= 5.20.3
nuget Fake.DotNet.FxCop >= 5.20.3
nuget Fake.DotNet.MSBuild >= 5.20.3
nuget Fake.DotNet.NuGet >= 5.20.3
nuget Fake.DotNet.Testing.NUnit >= 5.20.3
nuget Fake.DotNet.Testing.OpenCover >= 5.20.3
nuget Fake.DotNet.Testing.XUnit2 >= 5.20.3
nuget Fake.IO.FileSystem >= 5.20.3
nuget Fake.DotNet.Testing.Coverlet >= 5.20.3
nuget Fake.Testing.ReportGenerator >= 5.20.3
nuget Fake.Tools.Git >= 5.20.3
nuget AltCode.Fake.DotNet.Gendarme >= 5.18.1.24
nuget BlackFox.CommandLine >= 1.0.0
nuget BlackFox.VsWhere >= 1.1.0
nuget Markdig >= 0.24.0
nuget Manatee.Json >= 13.0.4
nuget NUnit >= 3.12.0
nuget Fuchu >= 1.1.0
nuget System.Text.Json >= 5.0.1
nuget Unquote >= 5.0.0
nuget YamlDotNet >= 8.1.2 //"
#r "System.IO.Compression.FileSystem.dll"
#r "System.Xml"
#r "System.Xml.Linq"
#load "../AltCover.Engine/NativeJson.fs"
#load "../AltCover.Engine/Abstract.fs"
#load "../AltCover.Engine/Primitive.fs"
#load "../AltCover.Engine/TypeSafe.fs"
#load "../AltCover.Engine/AltCover.fs"
#load "../AltCover.Engine/Args.fs"
#load "../AltCover.Fake.DotNet.Testing.AltCover/AltCoverCommand.fs"
#load "../AltCover.DotNet/DotNet.fs"
#load "../AltCover.Fake/Fake.fs"
#load "actions.fsx"
#load "targets.fsx"
#nowarn "988"
do ()"""
File.WriteAllText("./Build/build.fsx", build)
let _Target s f =
Target.description s
Target.create s f
let resetColours _ =
Console.ForegroundColor <- consoleBefore |> fst
Console.BackgroundColor <- consoleBefore |> snd
Target.description "ResetConsoleColours"
Target.createFinal "ResetConsoleColours" resetColours
Target.activateFinal "ResetConsoleColours"
_Target
"FxCop"
(fun _ ->
fxcop
|> Option.iter
(fun fx ->
Directory.ensure "./packages/fxcop/"
let target = Path.getFullName "./packages/fxcop/"
let prefix = fx.Length
let check t pf (f: string) =
let destination = t @@ (f.Substring pf)
// printfn "%A" destination
destination |> File.Exists |> not
Shell.copyDir target fx (check target prefix)
let rules = target @@ "Rules"
Shell.copyDir rules dixon (fun _ -> true)))
_Target "Preparation" ignore
let defaultTarget () =
resetColours ()
"Preparation"
"FxCop" =?> ("Preparation", Environment.isWindows)
Target.runOrDefault <| defaultTarget ()