-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.fsx
124 lines (92 loc) · 3.13 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
#I @"tools\FAKE\tools\"
#r @"tools\FAKE\tools\FakeLib.dll"
open Fake
open Fake.AssemblyInfoFile
open Fake.Git
open System.IO
let projectName = "Dynamics CRM Solution Exchanger"
//Directories
let buildDir = @".\build\"
let appBuildDir = buildDir + @"app\"
let deployDir = @".\Publish\"
let appdeployDir = deployDir + @"app\"
let packagesDir = @".\packages\"
let nugetDir = @".\nuget\"
let mutable version = "1.0"
let mutable build = buildVersion
let mutable nugetVersion = ""
let mutable asmVersion = ""
let mutable asmInfoVersion = ""
let mutable setupVersion = ""
let gitbranch = Git.Information.getBranchName "."
let sha = Git.Information.getCurrentHash()
Target "Clean" (fun _ ->
CleanDirs [buildDir; deployDir; nugetDir]
)
Target "RestorePackages" (fun _ ->
RestorePackages()
)
Target "BuildVersions" (fun _ ->
let safeBuildNumber = if not isLocalBuild then build else "1.0"
asmVersion <- safeBuildNumber
asmInfoVersion <- asmVersion + " - " + gitbranch + " - " + sha
setupVersion <- safeBuildNumber
nugetVersion <- safeBuildNumber
SetBuildNumber nugetVersion
)
Target "AssemblyInfo" (fun _ ->
BulkReplaceAssemblyInfoVersions "src/" (fun f ->
{f with
AssemblyVersion = asmVersion
AssemblyInformationalVersion = asmInfoVersion})
)
Target "BuildApp" (fun _->
let SetMSBuildToolsVersion (toolsVersion:string option) =
trace "Setting MSBuild tools version..."
match toolsVersion with
| Some version -> MSBuildHelper.MSBuildDefaults <- { MSBuildHelper.MSBuildDefaults with ToolsVersion = toolsVersion }
| None -> trace "No MSBuild tools version provided, using default."
Some "4.0" |> SetMSBuildToolsVersion
!! @"src\app\**\*.fsproj"
|> MSBuildRelease appBuildDir "Build"
|> Log "Build - Output: "
)
Target "CreateNuget" (fun _ ->
CreateDir nugetDir
"DynamicsCRMSolutionExchanger.nuspec"
|> NuGet (fun p ->
{p with
Project = projectName
Version = nugetVersion
NoPackageAnalysis = true
ToolPath = @".\tools\Nuget\Nuget.exe"
OutputPath = nugetDir
})
)
Target "PublishNuget" (fun _ ->
let nugetPublishDir = (deployDir + "nuget")
CreateDir nugetPublishDir
!! (nugetDir + "*.nupkg")
|> Copy nugetPublishDir
)
Target "Publish" (fun _ ->
CreateDir appdeployDir
!! (buildDir @@ @"/**/*.* ")
-- " *.pdb"
|> CopyTo appdeployDir
)
Target "Zip" (fun _ ->
!! (buildDir @@ @"\**\*.* ")
-- " *.zip"
|> Zip appBuildDir (deployDir + projectName + version + ".zip")
)
"Clean"
==> "RestorePackages"
==> "BuildVersions"
=?> ("AssemblyInfo", not isLocalBuild )
==> "BuildApp"
==> "Zip"
==> "Publish"
==> "CreateNuget"
==> "PublishNuget"
RunTargetOrDefault "Publish"