-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.fsx
180 lines (152 loc) · 6.15 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
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
175
176
177
178
179
180
// Copyright 2013 IntelliFactory
//
// Licensed under the Apache License, Version 2.0 (the "License"); you
// may not use this file except in compliance with the License. You may
// obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License.
#if BOOT
open Fake
module FB = Fake.Boot
FB.Prepare {
FB.Config.Default __SOURCE_DIRECTORY__ with
NuGetDependencies =
let ( ! ) x = FB.NuGetDependency.Create x
[
!"IntelliFactory.Build"
]
}
#else
#load ".build/boot.fsx"
open Fake
open System
open System.IO
open System.Net
open System.Text
module B = IntelliFactory.Build.CommonBuildSetup
module F = IntelliFactory.Build.FileSystem
module NG = IntelliFactory.Build.NuGetUtils
module VST = IntelliFactory.Build.VSTemplates
let ( +/ ) a b = Path.Combine(a, b)
let RootDir = __SOURCE_DIRECTORY__
let T x f = Target x f; x
module Config =
let PackageId = "IntelliFactory.FastInvoke"
let AssemblyVersion = Version "0.0"
let NuGetVersion = NG.ComputeVersion PackageId (global.NuGet.SemanticVersion AssemblyVersion)
let FileVersion = NuGetVersion.Version
let Company = "IntelliFactory"
let Description =
"Provides a faster alternative to calling `.Invoke` on \
`System.Reflection.MethodInfo` by separating the binding and invocation stages."
let LicenseUrl = "http://websharper.com/licensing"
let Tags = "F# Delegate Invocation".Split(' ') |> Array.toList
let Website = "http://bitbucket.org/IntelliFactory/fastinvoke"
let Metadata =
let m = B.Metadata.Create()
m.AssemblyVersion <- Some Config.AssemblyVersion
m.Author <- Some Config.Company
m.Description <- Some Config.Description
m.FileVersion <- Some Config.FileVersion
m.Product <- Some Config.PackageId
m.Website <- Some Config.Website
m
[<AutoOpen>]
module Extensions =
type B.BuildConfiguration with
static member Release(v: B.FrameworkVersion) : B.BuildConfiguration =
{
ConfigurationName = "Release"
Debug = false
FrameworkVersion = v
NuGetDependencies = new global.NuGet.PackageDependencySet(v.ToFrameworkName(), [])
}
type B.Solution with
static member Standard(rootDir: string)(m: B.Metadata)(ps: list<string -> B.Project>) : B.Solution =
B.Solution(rootDir, Projects = [for p in ps -> p rootDir], Metadata = m)
member this.BuildSync(?opts: B.MSBuildOptions) =
this.MSBuild(?options=opts)
|> Async.RunSynchronously
member this.CleanSync(?opts: B.MSBuildOptions) =
let opts : B.MSBuildOptions =
match opts with
| Some opts ->
{ opts with Targets = ["Clean"] }
| None ->
{
BuildConfiguration = None
Properties = Map.empty
Targets = ["Clean"]
}
this.MSBuild opts
|> Async.RunSynchronously
type B.Project with
static member FSharp(name: string)(configs: list<B.BuildConfiguration>)(rootDir: string) : B.Project =
{
Name = name
MSBuildProjectFilePath = Some (rootDir +/ name +/ (name + ".fsproj"))
BuildConfigurations = configs
}
static member CSharp(name: string)(configs: list<B.BuildConfiguration>)(rootDir: string) : B.Project =
{
Name = name
MSBuildProjectFilePath = Some (rootDir +/ name +/ (name + ".csproj"))
BuildConfigurations = configs
}
let C20 = B.BuildConfiguration.Release B.Net20
let C40 = B.BuildConfiguration.Release B.Net40
let Configs = [C20; C40]
let Solution : B.Solution =
B.Solution.Standard RootDir Metadata [
B.Project.FSharp "IntelliFactory.FastInvoke" Configs
]
/// TODO: helpers for buliding packages from a solution spec.
let BuildNuGetPackage = T "BuildNuGetPackage" <| fun () ->
let content =
use out = new MemoryStream()
let builder = new NuGet.PackageBuilder()
builder.Id <- Config.PackageId
builder.Version <- Config.NuGetVersion
builder.Authors.Add(Config.Company) |> ignore
builder.Owners.Add(Config.Company) |> ignore
builder.LicenseUrl <- Uri(Config.LicenseUrl)
builder.ProjectUrl <- Uri(Config.Website)
builder.Copyright <- String.Format("Copyright (c) {0} {1}", DateTime.Now.Year, Config.Company)
builder.Description <- Config.Description
Config.Tags
|> Seq.iter (builder.Tags.Add >> ignore)
for c in Configs do
for ext in [".xml"; ".dll"] do
let n = Config.PackageId
builder.Files.Add
(
let f = new NuGet.PhysicalPackageFile()
f.SourcePath <- RootDir +/ n +/ "bin" +/ ("Release-" + c.FrameworkVersion.GetMSBuildLiteral()) +/ (n + ext)
f.TargetPath <- "lib" +/ c.FrameworkVersion.GetNuGetLiteral() +/ (n + ext)
f
)
builder.Save(out)
F.Binary.FromBytes (out.ToArray())
|> F.BinaryContent
let out = RootDir +/ ".build" +/ String.Format("{0}.{1}.nupkg", Config.PackageId, Config.NuGetVersion)
content.WriteFile(out)
tracefn "Written %s" out
let BuildSolution = T "BuildSolution" Solution.BuildSync
let CleanSolution = T "CleanSolution" Solution.CleanSync
let Build = T "Build" ignore
let Clean = T "Clean" ignore
BuildSolution
==> BuildNuGetPackage
==> Build
CleanSolution
==> Clean
let Prepare = T "Prepare" <| fun () ->
B.Prepare (tracefn "%s") RootDir
RunTargetOrDefault Build
#endif