forked from henon/GitSharp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcommon-project.xml
258 lines (213 loc) · 11.1 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
<?xml version="1.0" ?>
<project name="GitSharp" 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 value="${msbuildlogger}" />
</exec>
</if>
<if test="${not build.msbuild}">
<property name="warnaserror" value="${build.warnaserrors}" />
<mkdir dir="${build.dir}" failonerror="false"/>
<csc
target="library"
define="${current.build.defines}"
debug="${build.debugoutput}"
optimize="${build.optimize}"
warnaserror="${warnaserror}"
output="${build.dir}/${project::get-name()}.dll"
doc="${build.dir}/${project::get-name()}.xml"
rebuild="${build.rebuild}"
>
<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.args}" />
</csc>
</if>
</target>
<target name="common.copy-references">
<foreach item="File" property="reference">
<in>
<items refid="project.references" />
</in>
<do>
<copy file="${reference}" todir="${build.dir}" overwrite="${build.rebuild}" />
</do>
</foreach>
</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()}'" />
<mkdir dir="${testresults.dir}" failonerror="false"/>
<property name="nunitcommandline" value="${project::get-name()}.dll /xml:${testresults.dir}/${project::get-name()}.dll-results.xml /config:${build.dir}/${project::get-name()}.dll.config /nologo /noshadow ${common.testrunner.args}" />
<if test="${(framework::get-family(framework::get-runtime-framework()) == 'mono')}">
<property name="nunitcommandline" value="${project::get-name()}.dll -xml:${testresults.dir}/${project::get-name()}.dll-results.xml -config:${build.dir}/${project::get-name()}.dll.config -nologo -noshadow -labels" />
</if>
<!-- Use nunit-console.exe if found, otherwise fall back to nunit2 task -->
<exec if="${nunit.found and not common.coverage.enabled}"
program="${nunit-console}"
workingdir="${build.dir}"
commandline="${nunitcommandline}"
failonerror="${common.testrunner.failonerror}"
timeout="180000"
/>
<!-- Run NCover if coverage is enabled -->
<if test="${common.coverage.enabled}">
<property name="assembly.under.test" value="${string::replace(project::get-name(), '.Tests', '')}" />
<exec
program="${ncover.dir}\NCover.Console.exe"
workingdir="${build.dir}"
commandline="${root.dir.absolute}/${nunit-console} ${nunitcommandline} //ias ${assembly.under.test} //x ${coverageresults.dir}/${assembly.under.test}.xml //ll Normal //l ${coverageresults.dir}/${assembly.under.test}.log"
failonerror="${common.testrunner.failonerror}"
timeout="240000"
/>
</if>
</if>
<if test="${not common.testrunner.enabled}">
<echo message="Tests are disabled for '${project::get-name()}'" />
</if>
</target>
</project>