-
Notifications
You must be signed in to change notification settings - Fork 5
/
reflector.build
244 lines (197 loc) · 11.4 KB
/
reflector.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
<?xml version="1.0" encoding="utf-8"?>
<project name="NetReflector" default="all" xmlns="http://nant.sf.net/release/0.86-beta1/nant.xsd">
<!-- properties -->
<property name="nant.verbosity" value="true" overwrite="false" />
<property name="build.configuration" value="Debug" overwrite="false" />
<property name="build.target" value="Build" overwrite="false" />
<property name="build.project" value="NetReflector.sln" overwrite="false" />
<property name="build.target.framework" value="3.5" overwrite="false" />
<property name="CCNetLabel" value="0.0.0.0" overwrite="false" />
<property name="codemetrics.output.type" value="XmlFile" overwrite="false" />
<!-- common path properties -->
<property name="src.dir" value="${path::get-full-path('src')}" readonly="true" />
<property name="build.dir" value="${path::get-full-path('Build')}" readonly="true" />
<property name="build.metrics.dir" value="${path::get-full-path('BuildMetrics')}" readonly="true" />
<property name="publish.dir" value="${path::get-full-path('Publish')}" readonly="true" />
<property name="tools.dir" value="${path::get-full-path('Tools')}" readonly="true" />
<property name="gendarme.project" value="${path::combine(src.dir, 'gendarme.assemblies.txt')}" overwrite="false" />
<property name="ndepend.project" value="${path::combine(src.dir, 'NDependProject.xml')}" overwrite="false" />
<property name="fxcop.project" value="${path::combine(src.dir, 'NetReflector.FxCop')}" overwrite="false" />
<!-- tool path properties -->
<property name="nauckit.nant.assembly" value="${path::combine( path::combine(tools.dir, 'NAnt'), 'NauckIT.NAnt.dll')}" readonly="true" />
<property name="gendarme.executable" value="${path::combine( path::combine(tools.dir, 'Gendarme'), 'gendarme.exe')}" readonly="true" />
<property name="ndepend.executable" value="${path::combine( path::combine(tools.dir, 'NDepend'), 'NDepend.Console.exe')}" readonly="true" />
<property name="fxcop.executable" value="${path::combine( path::combine(tools.dir, 'FxCop'), 'FxCopCmd.exe')}" readonly="true" />
<property name="nunit.executable" value="${path::combine( path::combine(tools.dir, 'NUnit'), 'nunit-console.exe')}" readonly="true" />
<!-- common assembly info properties -->
<property name="assembly.company" value="R. Owen Rogers and Contributors" readonly="true" />
<property name="assembly.product" value="NetReflector" readonly="true" />
<property name="assembly.copyright" value="Copyright © 2004 - ${datetime::get-year(datetime::now())} ${assembly.company}" readonly="true" />
<property name="assembly.trademark" value="" readonly="true" />
<property name="assembly.version" value="${CCNetLabel}" readonly="true" />
<property name="assembly.fileversion" value="${CCNetLabel}" readonly="true" />
<!-- Framework Support
http://nant.sourceforge.net/faq.html#framework-support
-->
<property name="nant.settings.currentframework" value="${framework::get-family(nant.settings.currentframework)}-${build.target.framework}" />
<!-- add a by msbuild required trailing slash to OutDir property -->
<if test="${platform::is-unix()}">
<property name="build.out.dir" value="${build.dir}/" />
</if>
<if test="${platform::is-windows()}">
<property name="build.out.dir" value="${build.dir}\" />
</if>
<!-- Targets -->
<target name="all" depends="clean, init, build, runTests, runCodeMetrics, package" description="" />
<target name="clean" description="Clean up">
<delete dir="${build.dir}" if="${directory::exists(build.dir)}" verbose="${nant.verbosity}" />
<delete dir="${publish.dir}" if="${directory::exists(publish.dir)}" verbose="${nant.verbosity}" />
</target>
<target name="init" description="Initial compilation setup">
<mkdir dir="${build.dir}" unless="${directory::exists(build.dir)}" verbose="${nant.verbosity}" />
<mkdir dir="${build.metrics.dir}" unless="${directory::exists(build.metrics.dir)}" verbose="${nant.verbosity}" />
<mkdir dir="${publish.dir}" unless="${directory::exists(publish.dir)}" verbose="${nant.verbosity}" />
</target>
<target name="createAssemblyInfo" description="Create an assembly info file with the current build number">
<asminfo language="CSharp" output="${path::combine(src.dir, 'CommonAssemblyInfo.cs')}" verbose="${nant.verbosity}">
<imports>
<import namespace="System.Reflection" />
</imports>
<attributes>
<attribute type="AssemblyCompanyAttribute" value="${assembly.company}" />
<attribute type="AssemblyProductAttribute" value="${assembly.product}" />
<attribute type="AssemblyCopyrightAttribute" value="${assembly.copyright}" />
<attribute type="AssemblyTrademarkAttribute" value="${assembly.trademark}" />
<attribute type="AssemblyVersionAttribute" value="${assembly.version}" />
<attribute type="AssemblyFileVersionAttribute" value="${assembly.fileversion}" />
</attributes>
</asminfo>
</target>
<target name="build" depends="init, createAssemblyInfo" description="Compilation of the build project">
<loadtasks assembly="${nauckit.nant.assembly}" />
<if test="${build.configuration == 'Debug'}">
<echo message="Build debug configuration" />
</if>
<if test="${build.configuration == 'Release'}">
<echo message="Build release configuration" />
</if>
<echo message="Source Directory: ${src.dir}" />
<echo message="Build Directory: ${build.out.dir}" />
<msbuild projectFile="${path::combine(src.dir, build.project)}" targets="${build.target}" verbosity="Minimal">
<property name="Configuration" value="${build.configuration}" />
<property name="OutputPath" value="${build.out.dir}" />
<property name="OutDir" value="${build.out.dir}" />
<!-- Hack for current xbuild issues on Mono 2.5 -->
<environment>
<!--<variable name="MONO_IOMAP" value="all" if="${framework::get-family(nant.settings.currentframework) == 'mono'}" />-->
<variable name="MONO_PATH" value="${path::get-full-path('lib')}" if="${framework::get-family(nant.settings.currentframework) == 'mono'}" />
</environment>
</msbuild>
</target>
<!-- Test targets -->
<target name="runTests" depends="build" description="Run unit tests">
<call target="runNUnitTests" cascade="false" />
</target>
<target name="runNUnitTests" depends="build" description="Run the NUnit tests">
<loadtasks assembly="${nauckit.nant.assembly}" />
<nunitTest executable="${nunit.executable}" workingDirectory="${build.dir}" outputFile="${path::combine(build.metrics.dir, 'nunit-result.xml')}" commandLineParameterFlag="-">
<assemblies>
<include name="${path::combine(build.dir, 'NetReflector.Test.dll')}" />
</assemblies>
<!-- Hack for current xbuild issues on Mono 2.5 -->
<environment>
<variable name="MONO_PATH" value="${path::get-full-path('lib')}" if="${framework::get-family(nant.settings.currentframework) == 'mono'}" />
</environment>
</nunitTest>
</target>
<!-- Code analyze metric targets -->
<target name="runCodeMetrics" depends="build" description="Analyze and collect code metrics of the compiled assemblies">
<call target="runGendarme" cascade="false" />
<!-- Execute Windows only code metric tools -->
<if test="${platform::is-windows()}">
<!-- Check for NDepend installation -->
<if test="${not file::exists(ndepend.executable)}">
<echo level="Warning" message="NDepend installation not found at '${ndepend.executable}'. Please install NDepend! Target canceled." />
</if>
<if test="${file::exists(ndepend.executable)}">
<call target="runNdepend" cascade="false" />
</if>
<!-- Run FxCop -->
<call target="runFxCop" cascade="false" />
</if>
</target>
<target name="runGendarme" depends="build" description="Analyze the compiled assemblies with Mono's Gendarme">
<loadtasks assembly="${nauckit.nant.assembly}" />
<if test="${codemetrics.output.type == 'LogFile'}">
<property name="gendarme.output.file" value="gendarme-result.log" />
</if>
<if test="${codemetrics.output.type == 'XmlFile'}">
<property name="gendarme.output.file" value="gendarme-result.xml" />
</if>
<if test="${codemetrics.output.type == 'HtmlFile'}">
<property name="gendarme.output.file" value="gendarme-result.html" />
</if>
<gendarme executable="${gendarme.executable}" outputType="${codemetrics.output.type}" outputFile="${path::combine(build.metrics.dir, gendarme.output.file)}"
workingDirectory="${build.out.dir}" assemblyListFile="${gendarme.project}" />
</target>
<target name="runNdepend" depends="build" description="Analyze and collect code metrics of the compiled assemblies with NDepend">
<loadtasks assembly="${nauckit.nant.assembly}" />
<ndepend executable="${ndepend.executable}" projectFile="${ndepend.project}" />
</target>
<target name="runFxCop" depends="build" description="Analyze the compiled assemblies with FxCop">
<loadtasks assembly="${nauckit.nant.assembly}" />
<if test="${codemetrics.output.type == 'LogFile'}">
<property name="fxcop.output.file" value="fxcop-result.html" />
<property name="fxcop.output.xsl" value="true" />
</if>
<if test="${codemetrics.output.type == 'XmlFile'}">
<property name="fxcop.output.file" value="fxcop-result.xml" />
<property name="fxcop.output.xsl" value="false" />
</if>
<if test="${codemetrics.output.type == 'HtmlFile'}">
<property name="fxcop.output.file" value="fxcop-result.html" />
<property name="fxcop.output.xsl" value="true" />
</if>
<fxcop executable="${fxcop.executable}" projectFile="${fxcop.project}" outputFile="${path::combine(build.metrics.dir, fxcop.output.file)}"
xslFile="${path::combine(build.metrics.dir, 'fxcop-report.xsl')}" applyXsl="${fxcop.output.xsl} "/>
</target>
<!-- packaging and publishing targets -->
<target name="package" depends="clean, build" description="Create and copy the NetReflector distribution to the publish dictionary">
<call target="packageSource" cascade="false" />
<call target="packageZipDistribution" cascade="false" />
</target>
<target name="packageSource" depends="clean, init" description="Creates a zip file containing all sources and tools to build NetReflector">
<property name="source.zip.file" value="NetReflector-${assembly.version}.source.zip" />
<zip zipfile="${path::combine(publish.dir, source.zip.file)}" verbose="${nant.verbosity}">
<fileset defaultexcludes="true">
<include name="*/**" />
<exclude name=".git/" />
<exclude name="nant*.log*" />
<exclude name="${build.dir}/**" />
<exclude name="${build.metrics.dir}/**" />
<exclude name="${publish.dir}/**" />
<exclude name="${tools.dir}/ncover*/**" />
<exclude name="${path::get-directory-name(ndepend.executable)}/**" />
<exclude name="${src.dir}/*/bin/**"/>
<exclude name="${src.dir}/*/obj/**"/>
<exclude name="${src.dir}/_Resharper*/**"/>
<exclude name="${src.dir}/**/*.user"/>
<exclude name="${src.dir}/**/*.suo"/>
<exclude name="${src.dir}/*.sln.cache"/>
<exclude name="${src.dir}/*.sln.proj"/>
</fileset>
</zip>
</target>
<target name="packageZipDistribution" depends="clean, build" description="Creates a zip file containing the NetReflector distribution">
<property name="dist.zip.file" value="NetReflector-${assembly.version}.zip" />
<zip zipfile="${path::combine(publish.dir, dist.zip.file)}" verbose="${nant.verbosity}">
<fileset defaultexcludes="true">
<include name="LICENSE.txt" />
</fileset>
<fileset basedir="${build.out.dir}" defaultexcludes="true">
<include name="NetReflector.dll" />
<include name="NetReflectorDocumenterTask.dll" />
</fileset>
</zip>
</target>
</project>