-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.fsx
121 lines (98 loc) · 4.34 KB
/
setup.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
// include Fake lib
#r @"src\packages\FAKE\tools\FakeLib.dll"
#r "System.Management.Automation"
#load @"lib\src\Helpers.fsx"
open Fake
open Fake.AssemblyInfoFile
open System.IO
open System.Linq
open System
open System.Diagnostics
open System.Management.Automation
open Helpers
//TraceEnvironmentVariables()
Target "RestorePackages" (fun _ ->
!! "./src/**/packages.config"
|> Seq.iter (RestorePackage (fun p ->
{ p with
OutputPath = "./src/packages"
Sources = [@"https://nuget.org/api/v2/"; @"https://www.myget.org/F/aspnetvnext/api/v2/"]}))
)
if buildServer = BuildServer.AppVeyor then
MSBuildLoggers <- @"""C:\Program Files\AppVeyor\BuildAgent\Appveyor.MSBuildLogger.dll""" :: MSBuildLoggers
// Version information
let majorVersion = 0
let minorVersion = 9
let patchLevel = 1
let buildVersion = System.DateTime.UtcNow.ToString("yyyyMMddhhmm")
let version = sprintf "%i.%i.%i-alpha+%s" majorVersion minorVersion patchLevel buildVersion
let productName = "FlexSearch"
let copyright = sprintf "Copyright (C) 2010 - %i - FlexSearch" DateTime.Now.Year
// Create necessary directories if they don't exist
ensureDirectory(buildDir)
ensureDirectory(testDir)
ensureDirectory(deployDir)
let AssemblyInfo path title =
CreateFSharpAssemblyInfo (sprintf @".\src\%s\AssemblyInfo.fs" path) [ Attribute.Title title
Attribute.Description title
Attribute.Product productName
Attribute.Copyright copyright
Attribute.FileVersion version
Attribute.Version version ]
let runPsScript scriptText =
let ps = PowerShell.Create()
let result = ps.AddScript(scriptText).Invoke()
trace "PS Script Output:\n"
result |> Seq.iter (sprintf "%A" >> trace)
if result.Count > 0 then
// Last exit code
if (result |> Seq.last).ToString() <> "0" then
failwith "The powershell script exited with a non-success code. Please check previous error messages for details."
if (ps.Streams.Error.Count > 0) then
trace "PS Script non-fatal errors:\n"
ps.Streams.Error |> Seq.iter (sprintf "%A" >> trace)
// Targets
Target "Clean" <| fun _ -> CleanDirs [ buildDir; testDir; deployDir ]
Target "BuildApp" <| fun _ ->
AssemblyInfo "ElMachina" "El Machina"
MSBuildRelease buildDir "Build" [ @"src\ElMachina.sln" ] |> Log "BuildApp-Output: "
// Copy the files from build to build-test necessary for Testing
FileHelper.CopyRecursive buildDir testDir true |> ignore
Target "Test" (fun _ ->
!! (testDir @@ "ElMachina.Tests.dll")
|> (fun includes ->
try FixieHelper.Fixie
(fun p -> { p with CustomOptions = [ "xUnitXml", "TestResult.xml" :> obj ] })
includes
// Upload test results to Appveyor even if tests failed
finally AppVeyor.UploadTestResultsXml AppVeyor.TestResultsType.Xunit __SOURCE_DIRECTORY__
trace "Uploaded to AppVeyor"))
Target "Zip" <| fun _ ->
!! (buildDir + "/**/ElMachina.dll")
++ (buildDir + "/elmachina/**/*.*")
|> Zip buildDir (deployDir <!!> "ElMachina." + version + ".zip")
// Portal related
Target "BuildPortal" <| fun _ ->
trace "Copying the portal files to the portal build directory"
FileHelper.CopyRecursive basePortalDir portalBuildDir true |> ignore
ensureDirectory (portalBuildDir <!!> "src/apps/elmachina")
FileHelper.CopyRecursive portalDir (portalBuildDir <!!> "src/apps/elmachina") true |> ignore
FileUtils.cd portalBuildDir
runPsScript <| File.ReadAllText "build.ps1"
FileUtils.cd rootDir
Target "DeployPortal" <| fun _ ->
ensureDirectory (buildDir <!!> "elmachina")
let baseSource = (portalBuildDir <!!> "src/apps/elmachina/dist")
!! (baseSource + "/**/*.*")
|> Seq.iter (FileHelper.CopyFileWithSubfolder baseSource (buildDir <!!> "elmachina"))
// Dependencies
"Clean"
==> "RestorePackages"
==> "BuildApp"
==> "DeployPortal"
==> "Zip"
==> "Test"
"BuildPortal"
==> "DeployPortal"
// start building core FlexSearch
RunTargetOrDefault "Zip"