forked from dnauck/Portable.Licensing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.fsx
190 lines (156 loc) · 6.42 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
181
182
183
184
185
186
187
188
189
190
// include Fake lib
#I @"packages/FAKE/tools"
#r @"FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open System
// build properties
let frameworkProfile = @"portable-net403+sl5+netcore45+wp8+MonoAndroid1+MonoTouch1" // profile 147
let buildTarget = getBuildParamOrDefault "buildTarget" "Build"
let buildConfiguration = getBuildParamOrDefault "buildConfiguration" "Release"
// common path properties
let sourceDir = currentDirectory @@ "src"
let buildDir = currentDirectory @@ "Build"
let buildMergedDir = buildDir @@ "merged"
let buildMetricsDir = currentDirectory @@ "BuildMetrics"
let distributionDir = currentDirectory @@ "Distribution"
let publishDir = currentDirectory @@ "Publish"
let solutionFile = sourceDir @@ "Portable.Licensing.sln"
// tools path properties
let toolsDir = currentDirectory @@ "Tools"
let nugetExecutable = "packages" @@ "NuGet.CommandLine" @@ "tools" @@ "NuGet.exe"
let mergerExecutable = toolsDir @@ "ILRepack" @@ "ILRepack.exe"
let xpkgExecutable = toolsDir @@ "xpkg" @@ "xpkg.exe"
// common assembly info properties
let assemblyVersion = getBuildParamOrDefault "assemblyVersion" "1.0.0.0"
let assemblyFileVersion = getBuildParamOrDefault "assemblyFileVersion" "1.1.0.0"
let assemblyInformationalVersion = getBuildParamOrDefault "assemblyInformationalVersion" "1.1.0"
// Targets
Target "All" DoNothing
Target "Clean" (fun _ ->
CleanDirs [
buildDir
buildMetricsDir
distributionDir
publishDir ]
)
Target "CreateAssemblyInfo" (fun _ ->
CreateCSharpAssemblyInfo (sourceDir @@ "CommonAssemblyInfo.cs")
[
Attribute.Company "Nauck IT KG"
Attribute.Product "Portable.Licensing"
Attribute.Copyright (sprintf "Copyright © 2012 - %A Nauck IT KG" DateTime.Now.Year)
Attribute.Version assemblyVersion
Attribute.FileVersion assemblyFileVersion
Attribute.InformationalVersion assemblyInformationalVersion
]
)
Target "Build" (fun _ ->
build (fun msbuild ->
{msbuild with
Targets = [buildTarget]
Properties = ["Configuration", buildConfiguration]
}
) solutionFile
)
Target "Test" (fun _ ->
!! (buildDir @@ "*Tests.dll")
|> NUnit (fun p ->
{p with
//DisableShadowCopy = true;
OutputFile = buildMetricsDir @@ "nunit-result.xml" })
)
Target "MergeAssemblies" (fun _ ->
CreateDir buildMergedDir
let result =
ExecProcess (fun info ->
info.FileName <- mergerExecutable
info.WorkingDirectory <- buildDir
info.Arguments <- sprintf "-target:library -internalize -verbose -lib:%s /out:%s %s %s" buildDir (buildMergedDir @@ "Portable.Licensing.dll") "Portable.Licensing.dll" "BouncyCastle.Crypto.dll"
) (TimeSpan.FromMinutes 5.)
if result <> 0 then failwithf "Error during ILRepack execution."
let filesToDelete =
!+ (buildDir @@ "Portable.Licensing.*")
++ (buildDir @@ "BouncyCastle.Crypto.*")
-- (buildDir @@ "Portable.Licensing.XML") |> Scan
DeleteFiles filesToDelete
let filesToCopy =
!+ (buildMergedDir @@ "Portable.Licensing.*") |> Scan
Copy buildDir filesToCopy
)
Target "PreparePackaging" (fun _ ->
// create the directory structure for the deployment zip and NuGet package
// and copy in the files to deploy
let docsDir = distributionDir @@ "Documentation"
CreateDir docsDir
CopyFile docsDir "Readme.md"
CopyFile docsDir "LICENSE.md"
let libsDir = distributionDir @@ "lib" @@ frameworkProfile
CreateDir libsDir
let librariesToDeploy =
!+ (buildDir @@ "Portable.Licensing.dll")
++ (buildDir @@ "Portable.Licensing.XML")
-- (buildDir @@ "Portable.Licensing.pdb") |> Scan
Copy libsDir librariesToDeploy
)
Target "PackgaeZipDistribution" (fun _ ->
Zip distributionDir (publishDir @@ String.Format(@"Portable.Licensing-{0}.zip", assemblyInformationalVersion)) !! (distributionDir @@ "**")
)
Target "PackageNuGetDistribution" (fun _ ->
// rename Readme.md to Readme.txt in the NuGet package, so that the file
// could be shown automaticly by VS during package installation
CopyFile distributionDir "Readme.md"
Rename (distributionDir @@ "Readme.txt") (distributionDir @@ "Readme.md")
let result =
ExecProcess (fun info ->
info.FileName <- nugetExecutable
info.WorkingDirectory <- "./"
info.Arguments <- sprintf "pack Portable.Licensing.nuspec -Version %s -OutputDirectory %s" assemblyInformationalVersion publishDir
) (TimeSpan.FromMinutes 5.)
if result <> 0 then failwithf "Error during NuGet creation."
// delete the renamed file
DeleteFile (distributionDir @@ "Readme.txt")
)
Target "PackageXamarinDistribution" (fun _ ->
xpkgPack (fun p ->
{p with
ToolPath = xpkgExecutable;
Package = "Portable.Licensing";
Version = assemblyFileVersion;
OutputPath = publishDir
Project = "Portable.Licensing"
Summary = "Portable.Licensing is a cross platform software licensing framework which allows you to implement licensing into your application or library"
Publisher = "Nauck IT KG"
Website = "http://dev.nauck-it.de/projects/portable-licensing"
Details = "./Xamarin/Details.md"
License = "License.md"
GettingStarted = "./Xamarin/GettingStarted.md"
Icons = ["./Xamarin/Portable.Licensing_512x512.png"; "./Xamarin/Portable.Licensing_128x128.png"]
Libraries = ["mobile", "./Distribution/lib/" @@ frameworkProfile @@ "/Portable.Licensing.dll"]
Samples = ["Android Sample. A simple sample that validates a trial license.", "./Samples/Android.Sample/Android.Sample.sln";
"iOS Sample. A simple sample that validates a trial license.", "./Samples/iOS.Sample/iOS.Sample.sln"]
}
)
xpkgValidate (fun p ->
{p with
ToolPath = xpkgExecutable;
Package = "Portable.Licensing";
Version = assemblyFileVersion;
OutputPath = publishDir
Project = "Portable.Licensing"
}
)
)
// Dependencies
"Clean"
==> "CreateAssemblyInfo"
==> "Build"
==> "Test"
==> "MergeAssemblies"
==> "PreparePackaging"
==> "PackgaeZipDistribution"
==> "PackageNuGetDistribution"
==> "PackageXamarinDistribution"
==> "All"
// start build
Run <| getBuildParamOrDefault "target" "All"