forked from Antaris/RazorEngine
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuildConfig.fsx
175 lines (146 loc) · 6.13 KB
/
buildConfig.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
// ----------------------------------------------------------------------------
// This file is subject to the terms and conditions defined in
// file 'LICENSE.txt', which is part of this source code package.
// ----------------------------------------------------------------------------
(*
This file handles the complete build process of RazorEngine
The first step is handled in build.sh and build.cmd by bootstrapping a NuGet.exe and
executing NuGet to resolve all build dependencies (dependencies required for the build to work, for example FAKE)
The secound step is executing this file which resolves all dependencies, builds the solution and executes all unit tests
*)
// Supended until FAKE supports custom mono parameters
#I @".nuget/Build/FAKE/tools/" // FAKE
#r @"FakeLib.dll" //FAKE
open System.Collections.Generic
open System.IO
open Fake
open Fake.Git
open Fake.FSharpFormatting
open AssemblyInfoFile
// properties
let projectName = "RazorEngine"
let projectSummary = "Simple templating using Razor syntax."
let projectDescription = "RazorEngine - A Templating Engine based on the Razor parser."
let projectName_roslyn = "RazorEngine.Roslyn"
let projectSummary_roslyn = "Roslyn extensions for RazorEngine."
let projectDescription_roslyn = "RazorEngine.Roslyn - Roslyn support for RazorEngine."
let authors = ["Matthew Abbott"; "Ben Dornis"; "Matthias Dittrich"]
let page_author = "Matthias Dittrich"
let mail = "[email protected]"
let version = "3.5.0.0"
let version_nuget = "3.5.0-beta2"
let version_razor4 = "4.0.0.0"
let version_razor4_nuget = "4.0.0-beta1"
let commitHash = Information.getCurrentSHA1(".")
//let buildTargets = environVarOrDefault "BUILDTARGETS" ""
//let buildPlatform = environVarOrDefault "BUILDPLATFORM" "MONO"
let buildDir = "./build/"
let releaseDir = "./release/"
let outLibDir = "./release/lib/"
let outDocDir = "./release/documentation/"
let docTemplatesDir = "./doc/templates/"
let testDir = "./test/"
let nugetDir = "./.nuget/"
let packageDir = "./.nuget/packages"
let github_user = "Antaris"
let github_project = "RazorEngine"
let nuget_url = "https://www.nuget.org/packages/RazorEngine/"
let tags = "C# razor template engine programming"
let buildMode = "Release" // if isMono then "Release" else "Debug"
// Where to look for *.cshtml templates (in this order)
let layoutRoots =
[ docTemplatesDir;
docTemplatesDir @@ "reference" ]
if isMono then
monoArguments <- "--runtime=v4.0 --debug"
//monoArguments <- "--runtime=v4.0"
let github_url = sprintf "https://github.com/%s/%s" github_user github_project
// Ensure the ./src/.nuget/NuGet.exe file exists (required by xbuild)
let nuget = findToolInSubPath "NuGet.exe" "./.nuget/Build/NuGet.CommandLine/tools/NuGet.exe"
System.IO.File.Copy(nuget, "./src/.nuget/NuGet.exe", true)
// Read release notes document
let release = ReleaseNotesHelper.parseReleaseNotes (File.ReadLines "doc/ReleaseNotes.md")
let MyTarget name body =
Target name body
Target (sprintf "%s_single" name) body
type BuildParams =
{
CustomBuildName : string
}
let buildApp (buildParams:BuildParams) =
let buildDir = buildDir @@ buildParams.CustomBuildName
CleanDirs [ buildDir ]
// build app
let files = !! "src/source/**/*.csproj"
let files =
(if buildParams.CustomBuildName = "net40" then
// dont build roslyn on net40
files
-- "src/**/RazorEngine.Core.Roslyn.csproj"
else files)
(if isMono then
files
// Don't build the mvc project on mono
-- "src/**/RazorEngine.Mvc.csproj"
else files)
|> MSBuild buildDir "Build"
[ "Configuration", buildMode
"CustomBuildName", buildParams.CustomBuildName ]
|> Log "AppBuild-Output: "
let buildTests (buildParams:BuildParams) =
let testDir = testDir @@ buildParams.CustomBuildName
CleanDirs [ testDir ]
// build tests
let files = !! "src/test/**/Test.*.csproj"
let files =
(if buildParams.CustomBuildName = "net40" then
// dont build roslyn on net40
files
-- "src/**/Test.RazorEngine.Core.Roslyn.csproj"
else files)
files
|> MSBuild testDir "Build"
[ "Configuration", buildMode
"CustomBuildName", buildParams.CustomBuildName ]
|> Log "TestBuild-Output: "
let runTests (buildParams:BuildParams) =
let testDir = testDir @@ buildParams.CustomBuildName
let logs = System.IO.Path.Combine(testDir, "logs")
System.IO.Directory.CreateDirectory(logs) |> ignore
let files =
!! (testDir + "/Test.*.dll")
// not working currently
-- (testDir + "/Test.RazorEngine.FSharp.dll")
let files =
(if isMono then
// While everything seems to work roslyn will sigsegv mono:
// https://travis-ci.org/Antaris/RazorEngine/builds/45375847
files
-- (testDir + "/Test.*.Roslyn.dll")
else files)
files
|> NUnit (fun p ->
{p with
//NUnitParams.WorkingDir = working
ExcludeCategory = if isMono then "VBNET" else ""
ProcessModel =
// Because the default nunit-console.exe.config doesn't use .net 4...
if isMono then NUnitProcessModel.SingleProcessModel else NUnitProcessModel.DefaultProcessModel
WorkingDir = testDir
StopOnError = true
TimeOut = System.TimeSpan.FromMinutes 30.0
Framework = "4.0"
DisableShadowCopy = true;
OutputFile = "logs/TestResults.xml" })
let net40Params = { CustomBuildName = "net40" }
let net45Params = { CustomBuildName = "net45" }
let razor4Params = { CustomBuildName = "razor4" }
// Documentation
let buildDocumentationTarget target =
trace (sprintf "Building documentation (%s), this could take some time, please wait..." target)
let b, s = executeFSI "." "generateDocs.fsx" ["target", target]
for l in s do
(if l.IsError then traceError else trace) (sprintf "DOCS: %s" l.Message)
if not b then
failwith "documentation failed"
()