forked from fsprojects/FAKE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-web-bundles.fsx
60 lines (51 loc) · 1.75 KB
/
build-web-bundles.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
#I @"tools/FAKE/tools/"
#r @"FakeLib.dll"
open System
open System.IO
open Fake
let buildDir = "./build-bundles"
let targetDir = "./src/deploy.web/Fake.Deploy.Web/Bundles"
let bundleDir = @"src\deploy.web\Fake.Deploy.Web.DataProviders"
let bundleProjects = !! (bundleDir + @"\**\*.*sproj")
Target "Clean" (fun _ ->
CleanDirs [buildDir; targetDir]
)
Target "SetAssemblyInfo" (fun _ ->
Directory.EnumerateDirectories(bundleDir)
|> Seq.map(fun d -> d, (Path.GetFileName(d)).Split([|'.'|]))
|> Seq.map(fun d -> fst d, snd d |> List.ofArray |> List.tail)
|> Seq.map(fun d -> fst d, String.Join(" ", snd d))
|> List.ofSeq
|> Seq.iter(fun d ->
let dir, name = d
AssemblyInfo
(fun p ->
{p with
CodeLanguage = FSharp
AssemblyVersion = buildVersion
AssemblyTitle = "FAKE - F# " + name + " Provider"
Guid = Guid.NewGuid().ToString()
OutputFileName = dir + @"\AssemblyInfo.fs"})
)
)
Target "BuildBundles" (fun _ ->
for bundle in bundleProjects do
let bundleBuild = buildDir @@ IO.Path.GetFileNameWithoutExtension(bundle)
MSBuildRelease bundleBuild "Build" [bundle] |> ignore
)
Target "ZipBundles" (fun _ ->
for dir in IO.Directory.EnumerateDirectories(buildDir) do
let dir = IO.DirectoryInfo(dir)
let name = targetDir @@ dir.Name + ".zip"
let files = IO.Directory.EnumerateFiles(dir.FullName, "*.*", IO.SearchOption.AllDirectories)
Zip dir.FullName name files
)
Target "Default" DoNothing
// Dependencies
"Clean"
=?> ("SetAssemblyInfo",not isLocalBuild)
==> "BuildBundles"
==> "ZipBundles"
==> "Default"
// start build
RunParameterTargetOrDefault "target" "Default"