-
Notifications
You must be signed in to change notification settings - Fork 11
/
EngagePublish.Build
411 lines (373 loc) · 18.7 KB
/
EngagePublish.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
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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
<?xml version="1.0" encoding="utf-8" ?>
<project xmlns="http://nant.sf.net/release/0.92/nant.xsd" name="Engage Build Script" basedir="." default="package">
<property name="projectName" value="Publish"/>
<property name="versions" value="6"/>
<property name="licenses" value="Free"/>
<property name="packageFileNameTemplate" value="${projectName}_${projectVersion}_${packageType}" dynamic="true"/>
<property name="dependencySourcePackageFileNameTemplate" value="${projectName}_${projectVersion}_DependencySource" dynamic="true"/>
<property name="createSourcePackage" value="true"/>
<property name="sourcePackageLicenseName" value="Free"/>
<property name="combineSourceWithInstallPackage" value="false"/>
<patternset id="dependencySourcePackages">
<include name="Engage.Framework_Source.zip"/>
<include name="Engage.Dnn.Framework_Source.zip"/>
</patternset>
<property name="projectDllName" value="Engage${projectName}.dll" />
<property name="solutionFile" value="Engage${projectName}_VS2008.sln"/>
<property name="binDirectory" value="..\..\bin" overwrite="false"/> <!-- binDirectory is readonly if set from the command line (i.e. during Team Build CI) -->
<property name="currentBinDirectory" value="${binDirectory}"/>
<property name="projectDll" value="${binDirectory}\${projectDllName}"/>
<patternset id="projectAssemblies">
<include name="${projectDll}"/>
</patternset>
<property name="testBuild" value="true" overwrite="false"/> <!-- testBuild is true if building from Visual Studio, false from Team Build (CI) -->
<property name="projectConfig" value="release"/>
<property name="projectConfig" value="Debug" if="${testBuild}"/>
<property name="zipLevel" value="9"/>
<property name="zipLevel" value="1" if="${testBuild}"/>
<property name="referencesDirectory" value="References"/>
<property name="packageDirectory" value="package"/>
<property name="packageName" value="Resources.zip"/>
<target name="package" description="Creates packages for this module, one for each value in the licenses and versions properties">
<call target="build"/>
<property name="assemblyFile" value="${projectDll}"/>
<call target="set-assemblyVersion"/>
<property name="projectVersion" value="${assemblyVersion}"/>
<call target="clean-package-folder"/>
<call target="setup-package-files"/>
<call target="create-resources-zip"/>
<property name="includeSource" value="false"/>
<foreach item="String" in="${licenses}" delim="," property="packageLicense">
<call target="create-packages"/>
</foreach>
<if test="${createSourcePackage}">
<property name="includeSource" value="true"/>
<property name="packageLicense" value="${sourcePackageLicenseName}"/>
<call target="add-sources-to-resource-zip"/>
<call target="create-packages"/>
<call target="get-dependency-source"/>
<if test="${combineSourceWithInstallPackage}">
<foreach item="String" in="${versions}" delim="," property="dnnVersion">
<call target="combine-source"/>
</foreach>
</if>
</if>
<call target="project-specific-tasks"/>
<call target="cleanup"/>
</target>
<target name="set-assemblyVersion" description="Sets the assemblyVersion property to the first three numbers from the version of the assembly specified by the assemblyFile property">
<property name="assemblyVersion" value="${format::version-info(fileversioninfo::get-version-info(assemblyFile))}" />
</target>
<target name="build" description="Builds solutionFile">
<exec program="${framework::get-framework-directory(framework::get-target-framework())}\msbuild.exe" failonerror="true">
<arg value="${solutionFile}" />
<arg value="/p:Configuration=${projectConfig}" />
<arg value="/p:Platform="Any CPU"" />
<arg value="/p:OutputPath="${currentBinDirectory}"" />
<arg value="/m" /> <!-- multicore -->
</exec>
</target>
<target name="clean-package-folder" description="Deletes all temporary files from package directory, then re-creates the folders to use">
<mkdir dir="${packageDirectory}" failonerror="false"/>
<delete dir="${packageDirectory}/temp/resources" failonerror="false"/>
<delete dir="${packageDirectory}/temp" failonerror="false"/>
<mkdir dir="${packageDirectory}/temp" failonerror="false" />
<mkdir dir="${packageDirectory}/temp/resources" failonerror="false" />
<mkdir dir="${packageDirectory}/temp/package" failonerror="false"/>
</target>
<target name="setup-package-files" description="Copies common package files to the temp/package directory, and sets version-dependent attributes in the DNN 6 manifest files">
<property name="releaseNotesFile" value="ReleaseNotes_${projectVersion}.htm"/>
<copy todir="${packageDirectory}/temp/package" flatten="true">
<fileset>
<include name="${releaseNotesFile}"/>
<include name="??.??.??.txt" />
<include name="ReadMe.txt" />
<include name="**/*.SqlDataProvider"/>
<include name="**/*.6.dnn"/>
</fileset>
</copy>
<copy todir="${packageDirectory}/temp/package/bin" flatten="true">
<fileset>
<patternset refid="projectAssemblies"/>
<include name="${referencesDirectory}/**/*.dll"/>
<exclude name="${referencesDirectory}/DotNetNuke.dll"/>
<exclude name="${referencesDirectory}/DotNetNuke.WebUtility.dll"/>
<exclude name="${referencesDirectory}/DotNetNuke.WebControls.dll"/>
<exclude name="${referencesDirectory}/DotNetNuke.Search.DataStore.dll"/>
<exclude name="${referencesDirectory}/Microsoft.ApplicationBlocks.Data.dll"/>
<exclude name="${referencesDirectory}/System.Web.Extensions.dll"/>
<exclude name="${referencesDirectory}/*.Design.dll"/>
<exclude name="${referencesDirectory}/Telerik.Web.UI.dll"/>
</fileset>
</copy>
<attrib readonly="false">
<fileset basedir="${packageDirectory}/temp/package">
<include name="**"/>
</fileset>
</attrib>
<if test="${file::exists(packageDirectory + '/temp/package/Engage' + projectName + '.6.dnn')}">
<xmlpoke file="${packageDirectory}/temp/package/Engage${projectName}.6.dnn" value="${releaseNotesFile}" xpath="dotnetnuke/packages/package/releaseNotes/@src" failonerror="false" />
<xmlpoke file="${packageDirectory}/temp/package/Engage${projectName}.6.dnn" value="${projectVersion}" xpath="dotnetnuke/packages/package/@version" failonerror="false" />
<xmlpoke file="${packageDirectory}/temp/package/Engage${projectName}.6.dnn" value="${projectVersion}" xpath="//*[@latestVersion='latestVersion']" failonerror="false" />
<foreach item="File" in="${packageDirectory}/temp/package/bin" property="assemblyFile">
<call target="set-assemblyVersion"/>
<xmlpoke file="${packageDirectory}/temp/package/Engage${projectName}.6.dnn" value="${assemblyVersion}" xpath="dotnetnuke/packages/package/components/component[@type='Assembly']/assemblies/assembly[name='${path::get-file-name(assemblyFile)}']/version" failonerror="false" />
</foreach>
<if test="${file::exists(referencesDirectory + '/DotNetNuke.dll')}">
<property name="assemblyFile" value="${referencesDirectory}/DotNetNuke.dll" />
<call target="set-assemblyVersion" />
<xmlpoke file="${packageDirectory}/temp/package/Engage${projectName}.6.dnn" value="${assemblyVersion}" xpath="dotnetnuke/packages/package/dependencies/dependency[@type='CoreVersion']" failonerror="false" />
</if>
</if>
</target>
<target name="create-resources-zip" description="Creates the Resources.zip file for content (Install package) files">
<copy todir="${packageDirectory}/temp/resources" flatten="false">
<fileset>
<patternset refid="content.fileset"/>
<exclude name="${packageDirectory}/**"/>
</fileset>
</copy>
<zip zipfile="${packageDirectory}/temp/package/${packageName}" ziplevel="${zipLevel}">
<fileset basedir="${packageDirectory}/temp/resources">
<include name="**/*"/>
</fileset>
</zip>
</target>
<target name="create-packages" description="For the given license and type, creates packages for DNN 6 (and above)">
<property name="licenseFile" value="EULA-${packageLicense}"/>
<call target="switch-license"/>
<foreach item="String" in="${versions}" delim="," property="dnnVersion">
<call target="zip-package"/>
</foreach>
</target>
<target name="switch-license" description="Switches out the license file and updates the reference to it in the DNN 6 manifest file">
<delete>
<fileset>
<include name="${packageDirectory}/temp/package/EULA-*"/>
</fileset>
</delete>
<copy todir="${packageDirectory}/temp/package" flatten="true">
<fileset>
<include name="Licenses/${licenseFile}.*"/>
</fileset>
</copy>
<if test="${file::exists(packageDirectory + '/temp/package/Engage' + projectName + '.6.dnn')}">
<xmlpoke file="${packageDirectory}/temp/package/Engage${projectName}.6.dnn" value="${licenseFile}.htm" xpath="dotnetnuke/packages/package/license/@src" failonerror="false" />
</if>
</target>
<target name="zip-package" description="Zips up the files in the temp/package directory, getting the correct manifest file and using the correct naming convention">
<property name="packageType" value="Install"/>
<property name="packageType" value="Source" if="${includeSource}"/>
<zip zipfile="${packageDirectory}/${packageFileNameTemplate}.zip">
<fileset basedir="${packageDirectory}/temp/package">
<include name="**/*"/>
</fileset>
</zip>
</target>
<target name="add-sources-to-resource-zip" description="Adds the files for the Source package to the Resources.zip file">
<copy todir="${packageDirectory}/temp/resources" flatten="false">
<fileset>
<patternset refid="source.fileset"/>
<exclude name="${packageDirectory}/**"/>
</fileset>
</copy>
<zip zipfile="${packageDirectory}/temp/package/${packageName}" ziplevel="${zipLevel}">
<fileset basedir="${packageDirectory}/temp/resources">
<include name="**/*"/>
</fileset>
</zip>
</target>
<target name="get-dependency-source" description="Gets the latest source packages for the Engage Framework dependencies for this module">
<property name="buildDirectory" value="_0.0"/>
<property name="buildPath" value="\\etg19\qa\Engage\Engage 3.0\Builds\"/>
<foreach item="Folder" in="${buildPath}" property="foldername" failonerror="false">
<property name="buildDirectory" value="${foldername}" if="${build-directory::is-greater-than(foldername, buildDirectory) and file::exists(path::combine(foldername, 'Release\Engage.Framework_Source.zip'))}"/>
</foreach>
<if test="${buildDirectory != '_0.0'}">
<property name="dependencyPackageDirectory" value="${packageDirectory}/temp/dependencies"/>
<copy todir="${dependencyPackageDirectory}">
<fileset basedir="${path::combine(buildDirectory, 'Release\')}">
<patternset refid="dependencySourcePackages"/>
</fileset>
</copy>
<call target="get-project-specific-dependencies"/>
<zip zipfile="${packageDirectory}/${dependencySourcePackageFileNameTemplate}.zip" ziplevel="${zipLevel}">
<fileset basedir="${packageDirectory}/temp/dependencies">
<include name="**/*"/>
</fileset>
</zip>
</if>
</target>
<target name="combine-source" description="Combines the Install and Source packages with the same license into one .zip file">
<property name="packageType" value="Install"/>
<property name="installPackageFileName" value="${packageFileNameTemplate}"/>
<property name="packageType" value="Source"/>
<property name="sourcePackageFileName" value="${packageFileNameTemplate}"/>
<zip zipfile="${packageDirectory}/${projectName}_${projectVersion}.zip">
<fileset basedir="${packageDirectory}">
<include name="${installPackageFileName}.zip"/>
<include name="${sourcePackageFileName}.zip"/>
<include name="${dependencySourcePackageFileNameTemplate}.zip"/>
</fileset>
</zip>
<delete file="${packageDirectory}/${installPackageFileName}.zip" failonerror="false"/>
<delete file="${packageDirectory}/${sourcePackageFileName}.zip" failonerror="false"/>
</target>
<target name="get-project-specific-dependencies" description="Puts source packages for any dependencies that can't be retrieved through the normal get-dependency-source target in dependencyPackageDirectory">
</target>
<target name="project-specific-tasks" description="Place tasks specific to the current project in this task">
</target>
<target name="cleanup" description="Deletes temporary files">
<delete file="${packageDirectory}\${projectName}_${projectVersion}_DependencySource.zip" failonerror="false"/>
<delete file="${packageDirectory}\${packageName}" failonerror="false"/>
<delete dir="${packageDirectory}\temp" failonerror="false"/>
</target>
<script language="C#" prefix="build-directory" >
<references>
<include name="System.dll" />
</references>
<imports>
<import namespace="System"/>
<import namespace="System.Globalization"/>
<import namespace="System.Text.RegularExpressions"/>
</imports>
<code>
<![CDATA[
[Function("is-greater-than")]
public static bool IsGreaterThan(string lhs, string rhs) {
return new BuildDirectory(lhs) > new BuildDirectory(rhs);
}
private struct BuildDirectory
{
private static readonly Regex buildDirectoryRegex = new Regex(@".*_(\d+\.\d+)", RegexOptions.Compiled | RegexOptions.CultureInvariant);
private Version buildNumber;
public BuildDirectory(string directoryName)
{
Match match = buildDirectoryRegex.Match(directoryName);
if (match.Success)
{
this.buildNumber = new Version(match.Groups[1].Value);
}
else
{
this.buildNumber = new Version(0,0);
}
}
public Version BuildNumber
{
get { return this.buildNumber; }
}
public static bool operator ==(BuildDirectory left, BuildDirectory right)
{
return left.Equals(right);
}
public static bool operator !=(BuildDirectory left, BuildDirectory right)
{
return !left.Equals(right);
}
public static bool operator <(BuildDirectory left, BuildDirectory right)
{
return left.buildNumber < right.buildNumber;
}
public static bool operator <=(BuildDirectory left, BuildDirectory right)
{
return left < right || left.Equals(right);
}
public static bool operator >(BuildDirectory left, BuildDirectory right)
{
return !(left <= right);
}
public static bool operator >=(BuildDirectory left, BuildDirectory right)
{
return !(left < right);
}
public bool Equals(BuildDirectory other)
{
return other.buildNumber == this.buildNumber;
}
public override bool Equals(object obj)
{
if (ReferenceEquals(null, obj))
{
return false;
}
if (obj.GetType() != typeof(BuildDirectory))
{
return false;
}
return this.Equals((BuildDirectory)obj);
}
public override int GetHashCode()
{
return this.buildNumber.GetHashCode();
}
}
]]>
</code>
</script>
<script language="C#" prefix="format" >
<references>
<include name="System.dll" />
</references>
<imports>
<import namespace="System.Diagnostics"/>
<import namespace="System.Globalization"/>
</imports>
<code>
<![CDATA[
[Function("version-info")]
public static string FormatVersionInfo(FileVersionInfo fileVersionInfo) {
return string.Format(CultureInfo.InvariantCulture, "{0:00}.{1:00}.{2:00}", fileVersionInfo.FileMajorPart, fileVersionInfo.FileMinorPart, fileVersionInfo.FileBuildPart);
}
]]>
</code>
</script>
<patternset id="content.fileset">
<include name="**/*.ascx" />
<include name="**/*.aspx" />
<include name="**/*.asmx" />
<include name="**/*.ashx" />
<include name="**/*.resx" />
<include name="**/*.html" />
<include name="**/*.htm" />
<include name="**/*.css" />
<include name="**/*.jpg" />
<include name="**/*.gif" />
<include name="**/*.png" />
<include name="**/*.pdf" />
<include name="**/*.xml" />
<include name="**/*.xsd" />
<include name="**/*.js" />
<exclude name="Licenses/EULA-*"/>
<exclude name="ReleaseNotes_*.htm"/>
<exclude name="??.??.??.txt" />
<exclude name="_ReSharper.*/**"/>
<exclude name="**/obj/**"/>
<exclude name="${referencesDirectory}/**"/>
<exclude name="**/bin/**"/>
</patternset>
<patternset id="source.fileset">
<include name="**/*.js"/>
<include name="**/*.cs"/>
<include name="**/*.vb"/>
<include name="**/*.sln"/>
<include name="**/*.csproj"/>
<include name="**/*.vbproj"/>
<include name="**/*.build"/>
<include name="**/*.dnn"/>
<include name="**/*.docx"/>
<include name="**/*.config"/>
<include name="**/*.dbml"/>
<include name="**/*.dbml.layout"/>
<include name="**/*.rpx"/>
<include name="**/*.txt"/>
<include name="Licenses/EULA-*"/>
<include name="ReleaseNotes_*.htm"/>
<include name="??.??.??.txt" />
<include name="MSBuild/*.dll"/>
<include name="MSBuild/*.targets"/>
<exclude name="**/obj/**"/>
<exclude name="Release.txt"/>
<exclude name="**/bin/**"/>
</patternset>
</project>