-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.fsx
120 lines (100 loc) · 3.51 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
#r "paket:
nuget Fake.Core.Target
nuget Fake.Core.Process
nuget Fake.DotNet.Cli
nuget Fake.Core.ReleaseNotes
nuget Fake.DotNet.AssemblyInfoFile
nuget Fake.DotNet.Paket
nuget Fake.Tools.Git
nuget Fake.Core.Environment
nuget Fake.Core.UserInput
nuget Fake.IO.FileSystem
nuget Fake.DotNet.MsBuild
nuget Fake.Api.GitHub
nuget Octokit < 0.50 //"
#load "./.fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.Tools
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.IO.Globbing.Operators
open Fake.Core.TargetOperators
open Fake.Api
open System
open System.IO
open System.IO.Compression
// make ZipFile available
#r "System.IO.Compression.FileSystem.dll"
let releaseNotes = ReleaseNotes.load "RELEASE_NOTES.md"
Target.create "Default" ignore
Target.create "Clean" (fun _ ->
let exitCode = Shell.Exec("dotnet", "clean")
if exitCode <> 0 then
failwith "dotnet clean failed")
Target.create "Build" (fun _ ->
let exitCode = Shell.Exec("dotnet", "build")
if exitCode <> 0 then
failwith "dotnet build failed")
Target.create "ReleaseBuild" (fun _ ->
let exitCode = Shell.Exec("dotnet", "build -c Release")
if exitCode <> 0 then
failwith "dotnet build failed")
Target.create "BuildAnalyzer" (fun _ ->
let analyzerProject = "src" </> "Avalonia.FuncUI.Analyzer"
let outputDirectory = __SOURCE_DIRECTORY__ </> "analyzers"
let args =
[ "pack"
"--configuration Release"
sprintf "/p:PackageVersion=%s" releaseNotes.NugetVersion
sprintf "/p:PackageReleaseNotes=\"%s\"" (String.concat "\n" releaseNotes.Notes)
sprintf "--output %s" outputDirectory ]
Shell.cleanDir outputDirectory
// create initial nuget package
let exitCode = Shell.Exec("dotnet", String.concat " " args, analyzerProject)
if exitCode <> 0 then
failwith "dotnet pack failed"
else
match Shell.Exec("dotnet", "publish --configuration Release --framework net6.0", analyzerProject) with
| 0 ->
let nupkg =
System.IO.Directory.GetFiles outputDirectory
|> Seq.head
|> IO.Path.GetFullPath
let nugetParent = DirectoryInfo(nupkg).Parent.FullName
let nugetFileName = IO.Path.GetFileNameWithoutExtension(nupkg)
let publishPath =
analyzerProject
</> "bin"
</> "Release"
</> "net6.0"
</> "publish"
// Unzip the nuget
ZipFile.ExtractToDirectory(nupkg, nugetParent </> nugetFileName)
// delete the initial nuget package
File.Delete nupkg
// remove stuff from ./lib/net6.0
Shell.deleteDir (
nugetParent
</> nugetFileName
</> "lib"
</> "net6.0"
)
// move the output of publish folder into the ./lib/net6.0 directory
Shell.copyDir
(nugetParent
</> nugetFileName
</> "lib"
</> "net6.0")
publishPath
(fun _ -> true)
// // re-create the nuget package
// ZipFile.CreateFromDirectory(nugetParent </> nugetFileName, nupkg)
// // delete intermediate directory
// Shell.deleteDir(nugetParent </> nugetFileName)
| _ -> failwith "dotnet publish failed")
"Clean" ==> "Build" ==> "Default"
"Clean" ==> "ReleaseBuild"
"Clean" ==> "BuildAnalyzer"
// start build
Target.runOrDefault "Default"