forked from nhibernate/nhibernate-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon-project.xml
232 lines (195 loc) · 8.45 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
<?xml version="1.0" ?>
<project xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd">
<description>
This file contains common tasks tailored specifically for the NHibernate
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, NHibernate directory.
After including the file, a target should be defined to initialize
configuration variables according to the project being built.
The standard name 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 file (.xml) and using Clover
if enabled.
- common.generate-assemblyinfo
generate an AssemblyInfo.cs file from assembly.* NAnt properties.
- common.run-tests
run compiled NUnit tests.
All compile/run targets put the output in bin.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 and
default to **/*.cs files and no files respectively.
</description>
<include buildfile="common.xml" />
<target name="common.clover-setup" if="${clover.enabled}">
<clover-setup
initstring="${root.dir}\${clover.db}"
builddir="${root.dir}\${clover.src}\${project::get-name()}"
enabled="${clover.instrument}"
flushinterval="1000"
/>
</target>
<target name="common.compile-tests"
depends="common.clover-setup"
description="Compile NUnit tests and copy App.config file to the output directory, if it exists.">
<csc
target="library"
define="${current.build.defines}"
debug="${build.debug}"
output="${bin.dir}/${project::get-name()}.dll"
>
<sources refid="project.sources" />
<references refid="project.references" />
<resources refid="project.resources" />
</csc>
<copy
file="App.config"
tofile="${bin.dir}/${project::get-name()}.dll.config"
if="${file::exists('App.config')}"
/>
</target>
<target name="common.compile-dll"
depends="common.clover-setup"
description="Compile sources into a DLL, using Clover if enabled">
<csc
target="library"
define="${current.build.defines}"
debug="${build.debug}"
output="${bin.dir}\${project::get-name()}.dll"
doc="${bin.dir}\${project::get-name()}.xml"
>
<nowarn>
<warning number="1591" /> <!-- No XML comment for publicly visible member -->
</nowarn>
<sources refid="project.sources" />
<references refid="project.references" />
<resources refid="project.resources" />
</csc>
</target>
<target name="common.compile-exe"
depends="common.clover-setup"
description="Compile sources into a console executable">
<csc
target="exe"
define="${current.build.defines}"
debug="${build.debug}"
output="${bin.dir}\${project::get-name()}.exe"
>
<nowarn>
<warning number="1591" /> <!-- No XML comment for publicly visible member -->
</nowarn>
<sources refid="project.sources" />
<references refid="project.references" />
<resources refid="project.resources" />
</csc>
</target>
<target name="common.set-assembly-attribute-values">
<property overwrite="false" name="assembly.is-cls-compliant" value="true" />
<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.version.numeric}" />
<property overwrite="false" name="assembly.version.informational" value="${project.version.numeric}" />
<property overwrite="false" name="assembly.version.file" value="${project.version.numeric}" />
<property overwrite="false" name="assembly.copyright" value="Licensed under LGPL." />
<property overwrite="false" name="assembly.keyfile" value="${key.file}" />
<property overwrite="false" name="assembly.sign" value="${sign}" />
<!--
Disable CLSCompliantAttribute for non-instrumented assemblies during Clover
build. The attribute causes build problems.
-->
<property name="assembly.is-cls-compliant" value="false" if="${clover.enabled and not clover.instrument}" />
</target>
<target name="common.generate-assemblyinfo"
depends="common.init common.set-assembly-attribute-values"
description="Generate AssemblyInfo.cs using assembly.* properties."
>
<attrib file="AssemblyInfo.cs" readonly="false" />
<asminfo output="AssemblyInfo.cs" language="CSharp">
<imports>
<import namespace="System" />
<import namespace="System.Reflection" />
<import namespace="System.Runtime.CompilerServices" />
<import namespace="System.Security" if="${assembly.allow-partially-trusted-callers}" />
</imports>
<attributes>
<attribute type="CLSCompliantAttribute" value="${assembly.is-cls-compliant}" />
<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.file}" />
<attribute type="AssemblyKeyFileAttribute" value="${assembly.keyfile}" if="${assembly.sign}"/>
<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.run-tests"
description="Run NUnit tests">
<nunit2>
<formatter
type="Xml"
usefile="true"
extension=".xml"
outputdir="${bin.dir}"
/>
<test
assemblyname="${bin.dir}\${project::get-name()}.dll"
appconfig="${bin.dir}\${project::get-name()}.dll.config" />
</nunit2>
</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="${bin.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="${bin.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>