-
Notifications
You must be signed in to change notification settings - Fork 42
/
Copy pathbuild.fsx
56 lines (44 loc) · 2.96 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
#r "paket: groupref BuildTools //"
#load "./.fake/build.fsx/intellisense.fsx"
open System.IO
open Fake.Core
open Fake.Core.TargetOperators
open Fake.IO
open Fake.IO.FileSystemOperators
open Fake.DotNet
let currentDirectory = new DirectoryInfo(System.Environment.CurrentDirectory)
let outputDir = new DirectoryInfo(currentDirectory.FullName @@ "Output")
let srcDir = new DirectoryInfo(currentDirectory.FullName @@ "src")
let buildOutput = new DirectoryInfo(srcDir.FullName @@ "ServiceBouncer" @@ "bin" @@ "Release")
Target.create "Clean" (fun _ ->
printfn "Clean & Ensure Output Directory"
DirectoryInfo.ensure outputDir
)
Target.create "Build" (fun _ ->
let setParams framework (defaults:MSBuildParams) = { defaults with Verbosity = Some(Quiet)
Targets = ["Clean,Rebuild"]
Properties = [
"Optimize", "True"
"DebugSymbols", "True"
"Configuration", (sprintf "Release%s" framework)
]
}
MSBuild.build (setParams "NET45") (srcDir.FullName @@ "ServiceBouncer.sln")
MSBuild.build (setParams "NET461") (srcDir.FullName @@ "ServiceBouncer.sln")
MSBuild.build (setParams "NET471") (srcDir.FullName @@ "ServiceBouncer.sln")
MSBuild.build (setParams "NET48") (srcDir.FullName @@ "ServiceBouncer.sln")
)
Target.create "Package" (fun _ ->
Zip.createZip buildOutput.FullName (outputDir.FullName @@ "ServiceBouncer.zip") "" Zip.DefaultZipLevel false ((DirectoryInfo.getMatchingFilesRecursive "*.*" buildOutput) |> Array.map(fun x -> x.FullName))
let nuspec = (srcDir.FullName @@ "Deploy" @@ "ServiceBouncer.nuspec")
let nugetExePath = currentDirectory.FullName @@ "packages" @@ "buildtools" @@ "NuGet.CommandLine" @@ "tools" @@ "NuGet.exe"
let args = sprintf @"pack ""%s"" -OutputDirectory ""%s"" -Properties Configuration=%s -NoPackageAnalysis -BasePath %s" nuspec outputDir.FullName "Release" srcDir.FullName
let result = Process.execWithResult ((fun info -> { info with FileName = nugetExePath
WorkingDirectory = srcDir.FullName
Arguments = args }) >> Process.withFramework) (System.TimeSpan.FromMinutes 5.)
if result.ExitCode <> 0 || result.Errors.Length > 0 then
failwithf "Error during NuGet package creation. %s %s\r\n%s" nugetExePath args (String.toLines result.Errors)
)
Target.create "Default" ignore
"Clean" ==> "Build" ==> "Package" ==> "Default" |> ignore
Target.runOrDefault "Default"