forked from fsprojects/FSharp.TypeProviders.SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
129 lines (106 loc) · 4.77 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
// --------------------------------------------------------------------------------------
// FAKE build script
// --------------------------------------------------------------------------------------
#I "packages/FAKE/tools"
#r "packages/FAKE/tools/FakeLib.dll"
open System
open System.IO
open Fake
// --------------------------------------------------------------------------------------
// Information about the project to be used at NuGet
// --------------------------------------------------------------------------------------
let project = "FSharp.TypeProviders.SDK"
let authors = ["Tomas Petricek"; "Gustavo Guerra"; "Michael Newton"; "Don Syme" ]
let summary = "Helper code and examples for getting started with Type Providers"
let description = """
The F# Type Provider SDK provides utilities for authoring type providers."""
let tags = "F# fsharp typeprovider"
let gitHome = "https://github.com/fsprojects"
let gitName = "FSharp.TypeProviders.SDK"
let config = "Release"
// Read release notes & version info from RELEASE_NOTES.md
Environment.CurrentDirectory <- __SOURCE_DIRECTORY__
let release =
File.ReadLines "RELEASE_NOTES.md"
|> ReleaseNotesHelper.parseReleaseNotes
let exec p args =
printfn "Executing %s %s" p args
Shell.Exec(p, args) |> function 0 -> () | d -> failwithf "%s %s exited with error %d" p args d
let pullRequest =
match getBuildParamOrDefault "APPVEYOR_PULL_REQUEST_NUMBER" "" with
| "" ->
trace "Master build detected"
None
| a ->
trace "Pull Request build detected"
Some <| int a
let buildNumber =
getBuildParamOrDefault "APPVEYOR_BUILD_VERSION" "0"
let version =
match pullRequest with
| None ->
sprintf "%s.%s" release.AssemblyVersion buildNumber
| Some num ->
sprintf "%s-pull-%d-%s" release.AssemblyVersion num buildNumber
let releaseNotes = release.Notes |> String.concat "\n"
let srcDir = "src"
let sources =
[srcDir @@ "ProvidedTypes.fsi"
srcDir @@ "ProvidedTypes.fs"
srcDir @@ "ProvidedTypesTesting.fs" ]
Target "Clean" (fun _ ->
CleanDirs []
)
Target "Restore" (fun _ ->
exec "dotnet" "restore src/FSharp.TypeProviders.SDK.fsproj"
exec "dotnet" "restore tests/FSharp.TypeProviders.SDK.Tests.fsproj"
exec "dotnet" "restore examples/BasicProvider/BasicProvider.fsproj"
exec "dotnet" "restore examples/ComboProvider/ComboProvider.fsproj"
exec "dotnet" "restore examples/BasicProvider.Tests/BasicProvider.Tests.fsproj"
exec "dotnet" "restore examples/ComboProvider.Tests/ComboProvider.Tests.fsproj"
)
Target "Build" (fun _ ->
exec "dotnet" ("build -c "+config+" src/FSharp.TypeProviders.SDK.fsproj")
exec "dotnet" ("build -c "+config+" tests/FSharp.TypeProviders.SDK.Tests.fsproj")
)
Target "Examples" (fun _ ->
//exec "dotnet" ("build -c "+config+" examples/BasicProvider/BasicProvider.fsproj")
//exec "dotnet" ("build -c "+config+" examples/ComboProvider/ComboProvider.fsproj")
//exec "dotnet" ("build -c "+config+" examples/BasicProvider.Tests/BasicProvider.Tests.fsproj")
//exec "dotnet" ("build -c "+config+" examples/ComboProvider.Tests/ComboProvider.Tests.fsproj")
()
)
Target "RunTests" (fun _ ->
#if MONO
// We don't use dotnet test because of https://github.com/dotnet/sdk/issues/335
// This is a bit of a hack to find the output tesat DLL and run xunit using Mono directly
let dir = "tests/bin/" + config + "/net461"
let file =
System.IO.Directory.GetDirectories(dir)
|> Array.pick (fun subdir ->
let file = subdir + "/FSharp.TypeProviders.SDK.Tests.dll"
if System.IO.File.Exists file then Some file else None)
exec "packages/xunit.runner.console/tools/net452/xunit.console.exe" (file + " -parallel none")
#else
exec "dotnet" ("test tests/FSharp.TypeProviders.SDK.Tests.fsproj -c " + config)
// This also gives console output:
// dotnet build tests\FSharp.TypeProviders.SDK.Tests.fsproj -c Debug -f net461 && packages\xunit.runner.console\tools\net452\xunit.console.exe tests\bin\Debug\net461\FSharp.TypeProviders.SDK.Tests.dll -parallel none
// msbuild tests/FSharp.TypeProviders.SDK.Tests.fsproj /p:Configuration=Debug && mono packages/xunit.runner.console/tools/net452/xunit.console.exe tests/bin/Debug/net461/FSharp.TypeProviders.SDK.Tests.dll -parallel none
#endif
()
)
Target "NuGet" (fun _ ->
#if !MONO
// We don't do this on Linux/OSX because of https://github.com/dotnet/sdk/issues/335
exec "dotnet" ("pack src/FSharp.TypeProviders.SDK.fsproj -c " + config)
#endif
()
)
"Clean"
==> "NuGet"
"Restore"
==> "Build"
==> "RunTests"
==> "Examples"
==> "NuGet"
RunTargetOrDefault "RunTests"