forked from dotless/dotless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
default.build
285 lines (234 loc) · 10.3 KB
/
default.build
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
<?xml version="1.0"?>
<project default="run">
<fail unless="${task::exists('trycatch') and task::exists('msbuild')}">
Error: nantcontrib is required. Please visit http://nantcontrib.sourceforge.net/ to download the latest version.
</fail>
<property name="config" value="debug" unless="${property::exists('config')}" />
<property name="showtestresult" value="false" unless="${property::exists('showtestresult')}" />
<property name="base_dir" value="${directory::get-current-directory()}" />
<property name="lib_dir" value="${path::combine(base_dir, 'lib')}" />
<property name="build_dir" value="${path::combine(base_dir, 'build')}" />
<property name="release_dir" value="${path::combine(base_dir, 'release')}" />
<property name="source_dir" value="${path::combine(base_dir, 'src')}" />
<target name="run" depends="Release" />
<target name="Clean">
<delete dir="${build_dir}" failonerror="false" />
<delete dir="${release_dir}" failonerror="false" />
</target>
<target name="Init" depends="Clean, Load-Git-Properties">
<echo>${version}</echo>
<property name="file" value="${source_dir}\dotless.Core\Properties\AssemblyInfo.cs" />
<property name="title" value="dotless ${version}" />
<property name="description" value="Dynamic CSS for .net" />
<property name="company" value="dotless project" />
<property name="product" value="dotless" />
<property name="copyright" value="Copyright © dotless project 2009-2012" />
<call target="Generate-Assembly-Info" />
<property name="file" value="${source_dir}\dotless.Test\Properties\AssemblyInfo.cs" />
<property name="title" value="dotless Tests ${version}" />
<call target="Generate-Assembly-Info" />
<property name="file" value="${source_dir}\dotless.Compiler\Properties\AssemblyInfo.cs" />
<property name="title" value="dotless Compiler ${version}" />
<call target="Generate-Assembly-Info" />
<property name="file" value="${source_dir}\dotless.AspNet\Properties\AssemblyInfo.cs" />
<property name="title" value="dotless AspNet ${version}" />
<call target="Generate-Assembly-Info" />
<mkdir dir="${build_dir}" />
<mkdir dir="${release_dir}" />
</target>
<target name="Build" depends="Init">
<trycatch>
<try>
<msbuild project="${source_dir}\dotless.Compiler\dotless.Compiler.csproj">
<arg value="/p:Configuration=${config}" />
<arg value="/p:OutDir=${build_dir}\" />
<arg value="/p:SignAssembly=true" />
<arg value="/p:AssemblyOriginatorKeyFile=../dotless-open-source.snk" />
</msbuild>
</try>
<catch>
<fail>Error: compile failed</fail>
</catch>
</trycatch>
</target>
<target name="Test" depends="Build">
<trycatch>
<try>
<msbuild project="${source_dir}\dotless.Test\dotless.Test.csproj">
<arg value="/p:Configuration=${config}" />
<arg value="/p:OutDir=${build_dir}\" />
</msbuild>
</try>
<catch>
<fail>Error: Test compile failed</fail>
</catch>
</trycatch>
<trycatch>
<try>
<exec program="nunit-console-x86.exe" basedir="${lib_dir}\NUnit" workingdir="${build_dir}">
<arg file="${build_dir}\dotless.Test.dll" />
</exec>
</try>
<catch>
<if test="${showtestresult}">
<exec program="start">
<arg file="${build_dir}\TestResult.xml" />
</exec>
</if>
<fail>Error: failed to execute tests</fail>
</catch>
</trycatch>
</target>
<target name="Merge" depends="Build" >
<property name="filename" value="dotless.Compiler.exe" />
<delete file="${build_dir}\${filename}-partial.exe" failonerror="false" />
<move file="${build_dir}\${filename}" tofile="${build_dir}\${filename}-partial.exe" />
<trycatch>
<try>
<exec program="ILMerge.exe" basedir="${lib_dir}\ilmerge" workingdir="${build_dir}">
<arg file="${build_dir}\${filename}-partial.exe" />
<arg file="${build_dir}\Pandora.dll" />
<arg file="${build_dir}\dotless.Core.dll" />
<arg file="${build_dir}\Microsoft.Practices.ServiceLocation.dll" />
<arg value="/out:${filename}" />
<arg value="/internalize" />
<arg value="/keyfile:../src/dotless-open-source.snk" />
<arg value="/t:exe" />
</exec>
</try>
<catch>
<fail>Error: Failed to merge compiler assemblies</fail>
</catch>
</trycatch>
<delete file="${build_dir}\${filename}-partial.exe" failonerror="false" />
<property name="filename" value="dotless.Core.dll" />
<delete file="${build_dir}\${filename}-partial.dll" failonerror="false" />
<move file="${build_dir}\${filename}" tofile="${build_dir}\${filename}-partial.dll" />
<trycatch>
<try>
<exec program="ILMerge.exe" basedir="${lib_dir}\ilmerge" workingdir="${build_dir}">
<arg file="${build_dir}\${filename}-partial.dll" />
<arg file="${build_dir}\dotless.AspNet.dll" />
<arg file="${build_dir}\Pandora.dll" />
<arg file="${build_dir}\Microsoft.Practices.ServiceLocation.dll" />
<arg value="/out:${filename}" />
<arg value="/internalize" />
<arg value="/keyfile:../src/dotless-open-source.snk" />
<arg value="/t:library" />
</exec>
</try>
<catch>
<fail>Error: Failed to merge assemblies</fail>
</catch>
</trycatch>
<delete file="${build_dir}\${filename}-partial.exe" failonerror="false" />
</target>
<target name="Release-NoTest" depends="Merge, Load-Git-Properties">
<exec program="7za.exe" basedir="${lib_dir}\7zip">
<arg line="a ${release_dir}\dotless-${commit}.zip" />
<arg file="${build_dir}\dotless.core.dll" />
<arg file="${build_dir}\dotless.core.pdb" />
<arg file="${build_dir}\dotless.compiler.dll" />
<arg file="${build_dir}\dotless.compiler.pdb" />
<arg file="${build_dir}\dotless.compiler.exe" />
<arg file="acknowledgements.txt" />
<arg file="license.txt" />
<!-- <arg file="${build_dir}\TestResult.xml" /> -->
</exec>
<echo>Please note that no tests where run during release process!</echo>
<echo>-----------------------------</echo>
<echo>dotless ${version} was successfully compiled and packaged.</echo>
<echo>The release bits can be found in "${release_dir}"</echo>
<echo>Thank you for using dotless!</echo>
</target>
<target name="t4css" depends="Merge, Load-Git-Properties">
<property name="target" value="${build_dir}\t4css" />
<mkdir dir="${build_dir}\t4css\T4CssWeb\Css" failonerror="false" />
<copy todir="${target}" file="${build_dir}\dotless.Core.dll" />
<copy todir="${target}" file="${base_dir}\t4less\T4Css.sln" />
<copy todir="${target}\T4CssWeb" file="${base_dir}\t4less\T4CssWeb\T4CssWeb.csproj" />
<copy todir="${target}\T4CssWeb\Css">
<fileset>
<include name="${base_dir}\t4less\T4CssWeb\Css\T4CSS.tt" />
<include name="${base_dir}\t4less\T4CssWeb\Css\*.less" />
<include name="${base_dir}\t4less\T4CssWeb\Css\*.css" />
<include name="${base_dir}\t4less\T4CssWeb\Css\*.log" />
</fileset>
</copy>
<exec program="7za.exe" basedir="${lib_dir}\7zip">
<arg line="a ${release_dir}\t4css-${commit}.zip" />
<arg file="${build_dir}\t4css" />
</exec>
</target>
<target name="Release" depends="Test, Merge, t4css, Load-Git-Properties">
<exec program="7za.exe" basedir="${lib_dir}\7zip">
<arg line="a ${release_dir}\dotless-${commit}.zip" />
<arg file="${build_dir}\dotless.core.dll" />
<arg file="${build_dir}\dotless.core.pdb" />
<arg file="${build_dir}\dotless.compiler.dll" />
<arg file="${build_dir}\dotless.compiler.pdb" />
<arg file="${build_dir}\TestResult.xml" />
<arg file="${build_dir}\dotless.compiler.exe" />
<arg file="acknowledgements.txt" />
<arg file="license.txt" />
</exec>
<echo>-----------------------------</echo>
<echo>dotless ${version} was successfully compiled and packaged.</echo>
<echo>The release bits can be found in "${release_dir}"</echo>
<echo>Thank you for using dotless!</echo>
</target>
<script language="C#" prefix="process">
<references><include name="system.dll"/></references>
<code>
<![CDATA[
[Function("git")]
public string RunGitCommand(string args) {
System.Diagnostics.Process process = new System.Diagnostics.Process();
process.StartInfo.FileName = "git";
process.StartInfo.Arguments = args;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.WorkingDirectory = Project.Properties["base_dir"];
process.Start();
StreamReader reader = process.StandardOutput;
string output = reader.ReadToEnd();
return output.Trim();
}
]]>
</code>
</script>
<target name="Load-Git-Properties" unless="${target::has-executed('Load-Git-Properties')}">
<trycatch>
<try>
<property name="commit" value="${process::git('describe')}" />
<property name="version" value="${process::git('describe --abbrev=0')}" />
<property name="version" value="${string::replace(version, 'v', '')}" />
</try>
<catch>
<fail>Unable to execute git-describe in folder '${directory::get-current-directory()}'. Please make sure that git is installed in your PATH</fail>
</catch>
</trycatch>
</target>
<target name="Generate-Assembly-Info" depends="Load-Git-Properties">
<mkdir dir="${path::get-directory-name(file)}" />
<asminfo output="${file}" language="CSharp">
<imports>
<import namespace="System.Reflection" />
<import namespace="System.Runtime.CompilerServices" />
<import namespace="System.Runtime.InteropServices" />
</imports>
<attributes>
<attribute type="ComVisibleAttribute" value="false" />
<attribute type="AssemblyTitleAttribute" value="${title}" />
<attribute type="AssemblyDescriptionAttribute" value="${description}" />
<attribute type="AssemblyCompanyAttribute" value="${company}" />
<attribute type="AssemblyProductAttribute" value="${product} ${commit}" />
<attribute type="AssemblyCopyrightAttribute" value="${copyright}" />
<attribute type="AssemblyVersionAttribute" value="${version}" />
<attribute type="AssemblyInformationalVersionAttribute" value="${version}" />
<attribute type="AssemblyFileVersionAttribute" value="${version}" />
<attribute type="AssemblyDelaySignAttribute" value="false" />
</attributes>
</asminfo>
</target>
</project>