Repository navigation
Expand file tree
/
Copy pathNModbus.build
More file actions
279 lines (244 loc) · 10.9 KB
/
Copy pathNModbus.build
File metadata and controls
279 lines (244 loc) · 10.9 KB
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
<?xml version="1.0"?>
<project default="all">
<include buildfile="NModbus.build.private" if="${file::exists('NModbus.build.private')}" />
<property name="path.fxcop" value="${environment::get-variable('FXCOP_HOME')}" />
<property name="path.framework" value="${environment::get-variable('SYSTEMROOT')}\Microsoft.NET\Framework\v3.5" />
<property name="path.ms.sdk" value="${environment::get-variable('MS_SDK_HOME')}" />
<property name="nantcontrib" value="${environment::get-variable('NANTCONTRIB_HOME')}\bin\NAnt.Contrib.Tasks.dll" />
<property name="path.bin" value="src\Modbus\bin\Release" />
<property name="path.full.signed.nmodbus.bin" value="src\Modbus\bin\SignedRelease" />
<property name="path.compact.signed.nmodbus.bin" value="src\Modbus\bin\SignedRelease\CompactFramework" />
<property name="path.signed.extensions.bin" value="src\Modbus.Extensions\bin\SignedRelease" />
<property name="path.ftd.bin" value="src\FtdAdapter\bin\Release" />
<property name="path.signed.ftd.bin" value="src\FtdAdapter\bin\SignedRelease" />
<property name="path.src" value="src" />
<property name="path.output" value="build" />
<property name="path.lib" value="lib" />
<property name="path.tools" value="tools" />
<property name="path.mbunit.console" value="${environment::get-variable('MBUNIT_HOME')}\bin\MbUnit.Cons.exe" />
<property name="path.mbunit.tasks" value="${path.tools}\MbUnit\MbUnit.Tasks.dll" />
<property name="path.nantgooglecode" value="${path.tools}\nant\NantGoogleCode.dll" />
<property name="path.jamod" value="${path.tools}\jamod" />
<property name="path.nmodbus" value="${path.tools}\nmodbus" />
<property name="path.docs" value="docs" />
<property name="path.dist" value="dist" />
<property name="version" value="1.11.0.0" />
<property name="product-name" value="NModbus_net-3.5_${version}" />
<setenv name="PATH" value="%PATH%;${path.fxcop}" />
<target name="build">
<exec program="${path.framework}\msbuild.exe" failonerror="true">
<arg value="src\NModbus.sln"/>
<arg line="/p:Configuration=Release"/>
</exec>
</target>
<target name="build-signed">
<exec program="${path.framework}\msbuild.exe" failonerror="true">
<arg value="src\NModbus.sln"/>
<arg line="/p:Configuration=SignedRelease"/>
</exec>
</target>
<target name="clean">
<foreach item="Folder" property="foldername">
<in>
<items basedir="src">
<include name="*"></include>
<exclude name="."></exclude>
</items>
</in>
<do>
<delete dir="${foldername}\bin" />
<delete dir="${foldername}\obj" />
</do>
</foreach>
<delete dir="${path.output}" />
<delete dir="${path.dist}" />
<delete dir="${path.docs}" />
</target>
<target name="run-unit-tests" depends="build">
<loadtasks assembly="${path.mbunit.tasks}"/>
<foreach item="Folder" property="foldername">
<in>
<items basedir="src">
<include name="*.UnitTests"></include>
<exclude name="."></exclude>
</items>
</in>
<do>
<mbunit
report-types="Xml"
report-filename-format="${foldername}.UnitTests"
report-output-directory="${path.output}"
failonerror="true">
<assemblies>
<include name="${foldername}\bin\Release\${path::get-file-name(foldername)}.dll" />
</assemblies>
</mbunit>
</do>
</foreach>
</target>
<target name="run-integration-tests" depends="build">
<loadtasks assembly="${path.mbunit.tasks}"/>
<foreach item="Folder" property="foldername">
<in>
<items basedir="src">
<include name="*.IntegrationTests"></include>
<exclude name="."></exclude>
</items>
</in>
<do>
<mbunit
report-types ="Xml"
report-filename-format="${foldername}.IntegrationTests"
report-output-directory="${path.output}"
failonerror="true">
<assemblies>
<include name="${foldername}\bin\Release\${path::get-file-name(foldername)}.dll" />
</assemblies>
</mbunit>
</do>
</foreach>
</target>
<target name="run-fxcop" depends="build">
<loadtasks assembly="${nantcontrib}"/>
<mkdir dir="${path.output}" failonerror="false"/>
<fxcop analysisReportFilename="${path.output}\fxcop.xml">
<targets>
<include name="${path.bin}\Modbus.dll" />
<include name="${path.bin}\Modbus.Extensions.dll" />
</targets>
</fxcop>
</target>
<target name="dist" depends="clean, setversion, build, build-signed, run-unit-tests, docs">
<!-- create scratch directory with the delay signed binaries to distribute -->
<mkdir dir="${path.dist}" />
<mkdir dir="${path.dist}\scratch" />
<!-- full .net framework version -->
<property name="path.dist.net" value="${path.dist}\scratch\net" />
<copy file="${path.full.signed.nmodbus.bin}\Modbus.dll" todir="${path.dist.net}" />
<copy file="${path.full.signed.nmodbus.bin}\log4net.dll" todir="${path.dist.net}" />
<copy file="${path.full.signed.nmodbus.bin}\Unme.Common.dll" todir="${path.dist.net}" />
<copy file="${path.signed.ftd.bin}\FtdAdapter.dll" todir="${path.dist.net}" />
<copy file="${path.signed.extensions.bin}\Modbus.Extensions.dll" todir="${path.dist.net}" />
<copy file="${path.lib}\FTD2XX.dll" todir="${path.dist.net}" />
<!-- .net compact framework version -->
<property name="path.dist.netcf" value="${path.dist}\scratch\netcf" />
<copy file="${path.compact.signed.nmodbus.bin}\Modbus.dll" todir="${path.dist.netcf}" />
<copy file="${path.compact.signed.nmodbus.bin}\log4net.dll" todir="${path.dist.netcf}" />
<copy file="${path.compact.signed.nmodbus.bin}\Unme.Common.dll" todir="${path.dist.netcf}" />
<copy file="${path.signed.extensions.bin}\Modbus.Extensions.dll" todir="${path.dist.netcf}" />
<!-- sign dlls with private key -->
<property name="path.privatekey" value="${environment::get-variable('PRIVATE_KEY_HOME')}\NModbus.snk" />
<foreach item="File" property="assembly">
<in>
<items basedir="${path.dist}\scratch">
<include name="**/Modbus.dll" />
<include name="**/Modbus.Extensions.dll" />
<include name="**/FtdAdapter.dll" />
</items>
</in>
<do>
<exec program="${path.ms.sdk}\bin\sn.exe" failonerror="true">
<arg value="-R" />
<arg value="${assembly}" />
<arg value ="${path.privatekey}" />
</exec>
</do>
</foreach>
<!-- create scratch directory with root files to distribute -->
<copy file="README.txt" todir="${path.dist}\scratch\root" />
<copy file="${path.docs}\Documentation.chm" tofile="${path.dist}\scratch\root\NModbus_net-3.5.chm" />
<!-- zip source distribution -->
<zip zipfile="${path.dist}\${product-name}-source.zip">
<fileset basedir="." prefix="source">
<include name="**" />
<exclude name="**/build/**" />
<exclude name="**/dist/**" />
<exclude name="**/*.suo" />
<exclude name="**/*.resharper" />
<exclude name="**/*.user" />
<exclude name="**/obj/**" />
<exclude name="**/bin/**" />
<exclude name="**/docs/**" />
<exclude name="README.txt" />
<exclude name="*.private" />
<exclude name="msbuild_log.xml" />
</fileset>
<fileset basedir="${path.dist}\scratch\root">
<include name="**" />
</fileset>
<fileset basedir="${path.dist}\scratch" prefix="bin">
<include name="net/**" />
<include name="netcf/**" />
</fileset>
</zip>
<!-- zip binary distribution -->
<zip zipfile="${path.dist}\${product-name}.zip">
<fileset basedir="${path.dist}\scratch\root">
<include name="**" />
</fileset>
<fileset basedir="${path.dist}\scratch" prefix="bin">
<include name="net/**" />
<include name="netcf/**" />
</fileset>
</zip>
</target>
<target name="all" depends="clean, build, run-unit-tests, run-integration-tests, run-fxcop" />
<target name="build-jamod">
<property name="path.jdk" value="${environment::get-variable('JDK_HOME')}" />
<exec program="${path.jdk}\bin\javac.exe" commandline="-classpath comm.jar;jamod.jar;. *.java" workingdir="${path.jamod}" />
</target>
<target name="build-nmodbus-test-driver">
<exec program="csc.exe" commandline="/r:modbus.dll *.cs" workingdir="${path.nmodbus}" />
</target>
<target name="setup-java" depends="build-jamod">
<property name="path.jre" value="${environment::get-variable('JRE_HOME')}" />
<copy file="${path.jamod}\javax.comm.properties" todir="${path.jre}\lib" />
<copy file="${path.jamod}\win32com.dll" todir="${path.jre}\bin" />
</target>
<target name="docs" depends="build">
<exec program="${path.framework}\msbuild.exe" failonerror="true">
<arg value="NModbus.shfbproj"/>
</exec>
</target>
<target name="setversion" description="Stamp the version info onto assemblyinfo.cs files">
<foreach item="File" property="filename">
<in>
<items basedir="src">
<include name="**\AssemblyInfo.cs"></include>
</items>
</in>
<do>
<echo message="Set version ${filename}" />
<script language="C#">
<code>
<![CDATA[
public static void ScriptMain(Project project)
{
StreamReader reader = new StreamReader(project.Properties["filename"]);
string contents = reader.ReadToEnd();
reader.Close();
string newText = Regex.Replace(contents, @"\[assembly: AssemblyVersion\("".*""\)\]",
String.Format("[assembly: AssemblyVersion(\"{0}\")]", project.Properties["version"]));
newText = Regex.Replace(newText, @"\[assembly: AssemblyFileVersion\("".*""\)\]",
String.Format("[assembly: AssemblyFileVersion(\"{0}\")]", project.Properties["version"]));
StreamWriter writer = new StreamWriter(project.Properties["filename"], false);
writer.Write(newText);
writer.Close();
}
]]>
</code>
</script>
</do>
</foreach>
</target>
<target name="upload" description="Uploads distribution to google code downloads page">
<if test="${not property::exists('gc.username') or not property::exists('gc.password')}">
<fail message="Private buildfile is missing or does not contain neccessary properties." />
</if>
<loadtasks assembly="${path.nantgooglecode}" />
<gcupload username="${gc.username}" password="${gc.password}" verbose="true" projectname="NModbus"
filename="${path.dist}\${product-name}.zip" targetfilename="${product-name}.zip" summary=".NET 3.5 NModbus ${version} Binaries" />
<gcupload username="${gc.username}" password="${gc.password}" verbose="true" projectname="NModbus"
filename="${path.dist}\${product-name}-source.zip" targetfilename="${product-name}-source.zip" summary=".NET 3.5 NModbus ${version} Source" />
</target>
</project>