-
Notifications
You must be signed in to change notification settings - Fork 934
/
Copy pathcommon-project.xml
166 lines (139 loc) · 6.63 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
<?xml version="1.0" ?>
<project xmlns="http://nant.sf.net/release/0.85-rc3/nant.xsd">
<description>
<![CDATA[
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-all
compile a solution, generating the documentation file (.xml)
- 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.download-nuget" depends="common.init">
<get
src="https://dist.nuget.org/win-x86-commandline/latest/nuget.exe"
dest="${tools.dir}/nuget.exe"
usetimestamp="true"
/>
</target>
<target name="common.nuget-restore" depends="common.init common.download-nuget">
<exec basedir="${tools.dir}" workingdir="${root.dir}/Tools" program="NuGet.exe">
<arg value="install" />
</exec>
</target>
<target name="common.solution-restore" depends="common.nuget-restore">
<exec program="${path::combine(tools.dir, 'msbuild.cmd')}" verbose="true">
<arg value="/t:Restore" />
<arg value="${root.dir}/src/NHibernate.sln" />
</exec>
</target>
<target name="common.compile-all" depends="common.nuget-restore nuget.set-properties">
<!--property name="msbuild.cmd" value="${cmd.sln} ${cmd.out} ${cmd.platform} ${cmd.debug} ${cmd.optimize} ${cmd.doc} /t:Rebuild /v:q /m" /-->
<exec program="${path::combine(tools.dir, 'msbuild.cmd')}" verbose="true">
<arg value="${root.dir}/src/NHibernate.sln" />
<arg value="/p:OutputPath="${path::get-full-path(bin.dir)}"" />
<arg value="/p:Platform="Any CPU"" />
<arg value="/p:Configuration="Debug"" if="${build.debug == 'true'}" />
<arg value="/p:Configuration="Release"" if="${build.release == 'true'}" />
<arg value="/p:GeneratePackageOnBuild="True"" />
<arg value="/p:IncludeSymbols="True"" />
<arg value="/p:IncludeSource="True"" />
<arg value="/p:PackageOutputPath="${path::get-full-path(nuget.nupackages.dir)}"" />
<arg value="/t:Restore" />
<arg value="/t:Rebuild" />
<arg value="/v:q" />
<arg value="/m" />
</exec>
</target>
<target name="common.run-tests"
description="Run NUnit tests">
<call target="common.find-nunit" unless="${property::exists('nunit.found')}" />
<property name="common.run-tests.failonerror" value="${not property::exists(test.file + '.IgnoreFail')}"/>
<property name="common.run-tests.x86" value="--x86" unless="${property::exists('nunit-x64')}" />
<property name="common.run-tests.x86" value="" if="${property::exists('nunit-x64')}" />
<property name="common.run-tests.teamcity" value="--teamcity" if="${property::exists('config.teamcity')}" />
<property name="common.run-tests.teamcity" value="" unless="${property::exists('common.run-tests.teamcity')}" />
<exec program="${nunit-console}" failonerror="${common.run-tests.failonerror}">
<arg line="${bin.dir}/${test.file}.dll --result=${testresults.dir}/${test.file}.dll-results.xml;format=nunit2 --framework=${framework::get-target-framework()} ${common.run-tests.teamcity} ${common.run-tests.x86}" />
</exec>
</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}/${test.file}.dll.config" />
<call target="common.put-connection-settings-into-defined-app-config" />
</target>
<target name="common.put-connection-settings-into-defined-app-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="//*/hbm:property[@name='dialect']"
value="${nhibernate.dialect}">
<namespaces>
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
</namespaces>
</xmlpoke>
<xmlpoke file="${app.config}"
xpath="//*/hbm:property[@name='command_timeout']"
value="${nhibernate.command_timeout}">
<namespaces>
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
</namespaces>
</xmlpoke>
<xmlpoke file="${app.config}"
xpath="//*/hbm:property[@name='connection.driver_class']"
value="${nhibernate.connection.driver_class}">
<namespaces>
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
</namespaces>
</xmlpoke>
<xmlpoke file="${app.config}"
xpath="//*/hbm:property[@name='connection.connection_string']"
value="${nhibernate.connection.connection_string}">
<namespaces>
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
</namespaces>
</xmlpoke>
<!-- Make sure the property exists - it's only set for some scenarios. -->
<property name="nhibernate.odbc.explicit_datetime_scale" value="" unless="${property::exists('nhibernate.odbc.explicit_datetime_scale')}"/>
<xmlpoke file="${app.config}"
xpath="//*/hbm:property[@name='odbc.explicit_datetime_scale']"
value="${nhibernate.odbc.explicit_datetime_scale}">
<namespaces>
<namespace prefix="hbm" uri="urn:nhibernate-configuration-2.2" />
</namespaces>
</xmlpoke>
</target>
<target name="common.remove-connection-settings-from-app-config">
<property name="app.config" value="${bin.dir}/${test.file}.dll.config" />
<xmlpoke
file="${app.config}"
xpath="/configuration/nhibernate/add[@key='hibernate.connection.connection_string']/@value"
value="conn string here"
/>
</target>
</project>