-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-project.xml
315 lines (260 loc) · 12.3 KB
/
common-project.xml
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
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<?xml version="1.0" ?>
<project name="Castle" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
<description>
This file contains common tasks tailored specifically for the Castle
build process. The goal was to define all the actions in this file, so
that actual project build files only have to configure a few variables
and call tasks in this file.
Usage
<property name="root.dir" value="../.." />
<include buildfile="${root.dir}/build-common/common-project.xml" />
These lines should be placed at the top level under the <project>
element. Property root.dir defines a relative path to the root of the
distribution, that is, Castle directory.
After including the file, a target should be defined to initialize
configuration variables according to the project being built.
The standard of this target is init (but any other name can be chosen).
The init target should depend on (or call) target common.init defined
in this file.
Other predefined targets are:
- common.compile-tests
compile NUnit tests and copy App.config file to the output directory,
if it exists.
- common.compile-dll
compile a DLL, generating the documentation and using Clover if enabled.
- common.generate-assemblyinfo, common.generate-assemblyinfoversion
generate an AssemblyInfo.cs or AssemblyInfoVersion.cs file from
assembly.* NAnt properties.
- common.run-tests
run compiled NUnit tests.
All compile/run targets put the output in build.dir. Common.compile*
targets use source fileset with id="project.sources", assembly fileset
with id="project.references" and resource fileset with id="project.resources"
to compile the project. The source and resource filesets are optional.
</description>
<include buildfile="common.xml" />
<target name="common.build">
<nant>
<buildfiles refid="buildfiles.all" />
</nant>
</target>
<target name="common.compile-tests"
description="Compile NUnit tests and copy App.config file to the output directory, if it exists.">
<call target="common.compile-dll" />
<!-- Check if there is a framework specific config file and use that -->
<property name="app.config.src" value="${src.dir}/App-${framework::get-target-framework()}.config" />
<if test="${file::exists(app.config.src)}">
<copy
file="${app.config.src}"
tofile="${build.dir}/${project::get-name()}.dll.config"
/>
<call target="common.configure-tests" />
<property name="app.config.src.found" value="true" />
</if>
<!-- In case there was no framework specific config check if there is a framework neutral file and use that. -->
<property name="app.config.src" value="${src.dir}/App.config" />
<if test="${file::exists(app.config.src)}" unless="${property::exists('app.config.src.found')}">
<copy
file="${app.config.src}"
tofile="${build.dir}/${project::get-name()}.dll.config"
/>
<call target="common.configure-tests" />
</if>
</target>
<target name="common.configure-tests"
description="Configure tests for running NUnit tests.">
<property name="app.config" value="${build.dir}/${project::get-name()}.dll.config" />
<!-- make sure the config file is writable -->
<attrib file="${app.config}" readonly="false" />
<xmlpoke
file="${app.config}"
xpath="/configuration/appSettings/add[@key='tests.src']/@value"
value="${src.dir}"
failonerror="false"
/>
</target>
<target name="common.compile-dll"
description="Compile sources into a DLL">
<if test="${build.msbuild}">
<property name="msbuildlogger" value="" overwrite="false" unless="${property::exists('CCNetLabel')}" />
<property name="msbuildlogger" value="/logger:ThoughtWorks.CruiseControl.MsBuild.XmlLogger" overwrite="false" if="${property::exists('CCNetLabel')}" />
<property name="msbuild.defines" value="${string::replace(current.build.defines, ',', ';')}" />
<exec program="${framework::get-framework-directory(framework::get-target-framework())}/MSBuild.exe" workingdir="${build.dir}">
<arg file="${src.dir}/${project.vsproj}" />
<arg value="/p:Configuration=${project.config}" />
<arg value="/p:OutputPath=${build.dir}" />
<arg value="/p:TreatWarningsAsErrors=${build.warnaserrors}" />
<arg value='/p:DefineConstants="${msbuild.defines}"' />
<arg value='/t:Rebuild' if="${build.rebuild}" />
<arg value="/p:DocumentationFile=${build.dir}/${project::get-name()}.xml" />
<arg value="/p:NoWarn=1591" unless="${build.warnmissingdocs}" />
<arg line="/p:SignAssembly=${assembly.sign} /p:AssemblyOriginatorKeyFile="${key.file}"" />
<arg value="${msbuildlogger}" />
</exec>
</if>
<if test="${not build.msbuild}">
<property name="warnaserror" value="${build.warnaserrors}" />
<csc
target="library"
define="${current.build.defines}"
debug="${build.debug}"
optimize="${build.optimize}"
warnaserror="${warnaserror}"
output="${build.dir}/${project::get-name()}.dll"
doc="${build.dir}/${project::get-name()}.xml"
rebuild="${build.rebuild}"
unless="${build.msbuild}"
>
<nowarn>
<warning number="1591" unless="${build.warnmissingdocs}" /> <!-- No XML comment for publicly visible member -->
</nowarn>
<sources refid="project.sources" />
<references refid="project.references" />
<resources refid="project.resources" />
<arg line=""${csc.keyfile}"" if="${assembly.sign}" />
<arg line="${csc.args}" />
</csc>
</if>
</target>
<target name="common.compile-website">
<property name="bin.dir" value="${src.dir}/bin" />
<mkdir dir="${bin.dir}" />
<delete file="${bin.dir}/${project::get-name()}.pdb" failonerror="false" /> <!-- To prevent 1.1 compiler from crashing when switching from a 2.0 build -->
<property name="build.dir" value="${bin.dir}" />
<call target="common.compile-dll" />
<call target="common.copy-references" />
</target>
<target name="common.copy-references">
<foreach item="File" property="reference">
<in>
<items refid="project.references" />
</in>
<do>
<copy file="${reference}" todir="${bin.dir}" overwrite="${build.rebuild}" />
</do>
</foreach>
</target>
<target name="common.compile-exe"
description="Compile sources into a console executable">
<property name="output-file" overwrite="false" value="${project::get-name()}" />
<csc
target="exe"
define="${current.build.defines}"
debug="${build.debug}"
optimize="${build.optimize}"
warnaserror="${build.warnaserrors}"
output="${build.dir}/${output-file}.exe"
>
<nowarn>
<warning number="1591" unless="${build.warnmissingdocs}" /> <!-- No XML comment for publicly visible member -->
</nowarn>
<sources refid="project.sources" />
<references refid="project.references" />
<resources refid="project.resources" />
<arg line=""${csc.keyfile}"" if="${assembly.sign}" />
<arg line="${csc.args}" />
</csc>
</target>
<target name="common.set-assembly-attribute-values">
<property overwrite="false" name="assembly.is-cls-compliant" value="true" />
<property overwrite="false" name="assembly.is-com-visible" value="false" />
<property overwrite="false" name="assembly.guid" value="" />
<property overwrite="false" name="assembly.allow-partially-trusted-callers" value="false" />
<property overwrite="false" name="assembly.description" value="" />
<property overwrite="false" name="assembly.product" value="${project::get-name()}" />
<property overwrite="false" name="assembly.company" value="${project.company}" />
<property overwrite="false" name="assembly.title" value="${project::get-name()} for ${framework::get-description(framework::get-target-framework())}" />
<property overwrite="false" name="assembly.version" value="${project.major}.${project.minor}.${project.build}.0" />
<property overwrite="false" name="assembly.version.informational" value="${assembly.major}.${assembly.minor}.${assembly.build}.${svn.revision}" />
<property overwrite="false" name="assembly.copyright" value="Castle Project, original author or authors" />
<property overwrite="false" name="assembly.keyfile" value=""${key.file}"" />
<property overwrite="false" name="assembly.sign" value="${sign}" />
</target>
<target name="common.generate-assemblyinfo"
depends="common.init common.set-assembly-attribute-values"
description="Generate AssemblyInfo.cs using assembly.* properties."
>
<property name="assemblyinfo.cs" value="${path::combine(src.dir,'AssemblyInfo.cs')}" />
<attrib file="${assemblyinfo.cs}" readonly="false" />
<asminfo output="${assemblyinfo.cs}" language="CSharp" failonerror="false">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Runtime.CompilerServices" />
<import namespace="System.Runtime.InteropServices" />
<import namespace="System.Security" if="${assembly.allow-partially-trusted-callers}" />
</imports>
<attributes>
<attribute type="CLSCompliantAttribute" value="${assembly.is-cls-compliant}" />
<attribute type="ComVisibleAttribute" value="${assembly.is-com-visible}" />
<attribute type="GuidAttribute" value="${assembly.guid}" if="${assembly.guid != ''}" />
<attribute type="AssemblyTitleAttribute" value="${assembly.title}" />
<attribute type="AssemblyDescriptionAttribute" value="${assembly.description}" />
<attribute type="AssemblyCompanyAttribute" value="${assembly.company}" />
<attribute type="AssemblyProductAttribute" value="${assembly.product}" />
<attribute type="AssemblyCopyrightAttribute" value="${assembly.copyright}" />
<attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
<attribute type="AssemblyInformationalVersionAttribute" value="${assembly.version.informational}" />
<attribute type="AssemblyFileVersionAttribute" value="${assembly.version.informational}" />
<attribute type="AssemblyDelaySignAttribute" value="false" />
<!-- For some reason, NAnt doesn't detect that APTCA has a public no-argument constructor -->
<attribute asis="true" type="AllowPartiallyTrustedCallersAttribute" if="${assembly.allow-partially-trusted-callers}" />
</attributes>
</asminfo>
</target>
<target name="common.assemblyinfo">
<nant target="generate-assemblyinfo">
<buildfiles refid="buildfiles.all" />
</nant>
</target>
<target name="common.run-tests"
description="Run NUnit tests">
<if test="${common.testrunner.enabled}">
<call target="common.find-nunit" unless="${property::exists('nunit.found')}" />
<echo message="Running tests in '${project::get-name()}'" />
<!-- Use nunit-console.exe if found, otherwise fall back to nunit2 task -->
<exec if="${nunit.found}"
program="${nunit-console}"
workingdir="${build.dir}"
commandline="${project::get-name()}.dll /xml:${testresults.dir}/${project::get-name()}.dll-results.xml /config:${build.dir}/${project::get-name()}.dll.config /nologo"
failonerror="${common.testrunner.failonerror}"
/>
</if>
<if test="${not common.testrunner.enabled}">
<echo message="Tests are disabled for '${project::get-name()}'" />
</if>
</target>
<target name="common.run-database-tests"
depends="common.put-connection-settings-into-app-config common.run-tests common.remove-connection-settings-from-app-config" />
<target name="common.put-connection-settings-into-app-config">
<property name="app.config" value="${build.dir}/${project::get-name()}.dll.config" />
<!-- make sure the config file is writable -->
<attrib file="${app.config}" readonly="false" />
<!--
Tell nhibernate how to connect to the test database.
-->
<xmlpoke
file="${app.config}"
xpath="/configuration/nhibernate/add[@key='hibernate.dialect']/@value"
value="${nhibernate.dialect}"
/>
<xmlpoke
file="${app.config}"
xpath="/configuration/nhibernate/add[@key='hibernate.connection.driver_class']/@value"
value="${nhibernate.connection.driver_class}"
/>
<xmlpoke
file="${app.config}"
xpath="/configuration/nhibernate/add[@key='hibernate.connection.connection_string']/@value"
value="${nhibernate.connection.connection_string}"
/>
</target>
<target name="common.remove-connection-settings-from-app-config">
<property name="app.config" value="${build.dir}/${project::get-name()}.dll.config" />
<xmlpoke
file="${app.config}"
xpath="/configuration/nhibernate/add[@key='hibernate.connection.connection_string']/@value"
value="conn string here"
/>
</target>
</project>