forked from fhaag/namebasedgrid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrelease.build
225 lines (200 loc) · 7.42 KB
/
release.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
<?xml version="1.0"?>
<!--
This source file is a part of Name-Based Grid.
Copyright (c) 2015 Florian Haag
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<project name="Name-Based Grid Release" default="help" basedir=".">
<property name="release.version" value="0.0.0" overwrite="false"/>
<property name="project.name" value="Name-Based Grid" readonly="true"/>
<property name="release.fileprefix" value="NameBasedGrid" readonly="true"/>
<tstamp property="internal.user-friendly-date" pattern="yyyy-MM-dd"/>
<!-- ================ Documentation ================ -->
<target name="help">
<echo>Name-Based Grid</echo>
<echo>===============</echo>
<echo>This Nant build file offers the following targets:</echo>
<echo>== release ==</echo>
<echo>Assembles all release files. This requires NuGet to be installed</echo>
<echo>on the search path. The Release version of the assemblies and</echo>
<echo>the CHM help file must already have been built.</echo>
<echo>== publish ==</echo>
<echo>Publishes the files. The release target must have been run before.</echo>
<echo>The following steps are executed:</echo>
<echo>* Publish on NuGet:</echo>
<echo> (publish-NuGet)</echo>
<echo> NuGet must be on the path and a valid API key must be set.</echo>
</target>
<!-- ================ Release Files ================ -->
<patternset id="srcfiles">
<include name="**/*.sln"/>
<include name="**/*.csproj"/>
<include name="**/*.cs"/>
<include name="**/*.xaml"/>
<include name="**/*.ico"/>
<include name="**/readme.txt"/>
<include name="**/*.LICENSE"/>
<include name="**/*.snk"/>
<include name="**/*.resx"/>
<exclude name="**/bin/**"/>
<exclude name="**/obj/**"/>
</patternset>
<patternset id="binfiles">
<include name="*.dll"/>
<include name="*.xml"/>
<exclude name="*.CodeAnalysisLog.xml"/>
</patternset>
<target name="prepare-readme" depends="clean">
<mkdir dir="buildtmp/readme"/>
<copy file="COPYING" tofile="buildtmp/readme/COPYING"/>
<copy file="changelog.txt" tofile="buildtmp/readme/changelog.txt"/>
<copy file="readme.txt" tofile="buildtmp/readme/readme.txt">
<filterchain>
<replacetokens begintoken="%" endtoken="%">
<token key="VERSION" value="${release.version}"/>
<token key="DATE" value="${internal.user-friendly-date}"/>
</replacetokens>
</filterchain>
</copy>
</target>
<target name="clean">
<delete dir="release" if="${directory::exists('release')}"/>
<delete dir="buildtmp" if="${directory::exists('buildtmp')}"/>
</target>
<target name="release" depends="clean,prepare-readme">
<mkdir dir="release"/>
<mkdir dir="buildtmp/exampleprojects"/>
<copy todir="buildtmp/exampleprojects">
<fileset basedir="src/Samples">
<include name="*/*.csproj"/>
</fileset>
</copy>
<foreach item="Folder" in="buildtmp/exampleprojects" property="foldername">
<copy file="src/Version.cs" tofile="${foldername}/Properties/Version.cs"/>
<foreach item="File" in="${foldername}" property="filename">
<in>
<items>
<include name="*.csproj"/>
</items>
</in>
<do>
<xmlpoke file="${filename}" xpath="/ms:Project/ms:ItemGroup[ms:ProjectReference[ms:Name = 'NameBasedGrid']]" value="<Reference Include="NameBasedGrid"><HintPath>..\bin\NameBasedGrid.dll</HintPath></Reference>">
<namespaces>
<namespace prefix="ms" uri="http://schemas.microsoft.com/developer/msbuild/2003"/>
</namespaces>
</xmlpoke>
<xmlpoke file="${filename}" xpath="/ms:Project/ms:ItemGroup/ms:Compile[ms:Link = 'Properties\Version.cs']/@Include" value="Properties\Version.cs">
<namespaces>
<namespace prefix="ms" uri="http://schemas.microsoft.com/developer/msbuild/2003"/>
</namespaces>
</xmlpoke>
<xmlpoke file="${filename}" xpath="/ms:Project/ms:ItemGroup/ms:Compile[ms:Link = 'Properties\Version.cs']" value="">
<namespaces>
<namespace prefix="ms" uri="http://schemas.microsoft.com/developer/msbuild/2003"/>
</namespaces>
</xmlpoke>
</do>
</foreach>
</foreach>
<zip zipfile="release/${release.fileprefix}-${release.version}-bin.zip">
<fileset basedir="bin/Release" prefix="bin">
<patternset refid="binfiles"/>
</fileset>
<fileset basedir="src/Samples">
<patternset refid="srcfiles"/>
<exclude name="**/*.csproj"/>
</fileset>
<fileset basedir="src/Samples">
<include name="*/bin/Release/*.exe"/>
<include name="*/bin/Release/*.dll"/>
</fileset>
<fileset basedir="buildtmp/exampleprojects">
<include name="*/*.csproj"/>
<include name="**/*.cs"/>
<include name="**/*.xaml"/>
</fileset>
<fileset basedir="buildtmp/readme">
<include name="*"/>
</fileset>
</zip>
<zip zipfile="release/${release.fileprefix}-${release.version}-src.zip">
<fileset basedir="src" prefix="src">
<patternset refid="srcfiles"/>
</fileset>
<fileset basedir="keys" prefix="keys">
<patternset refid="srcfiles"/>
</fileset>
<fileset>
<include name="doc/*.shfbproj"/>
<include name="pubinfo/*.svg"/>
<include name="pubinfo/*.nuspec"/>
<include name="*.build"/>
<include name="*.bat"/>
</fileset>
<fileset basedir="buildtmp/readme">
<include name="*"/>
</fileset>
</zip>
<zip zipfile="release/${release.fileprefix}-${release.version}-help.zip">
<fileset basedir="doc/Help">
<include name="*.chm"/>
</fileset>
<fileset basedir="buildtmp/readme">
<include name="*"/>
</fileset>
</zip>
<copy todir="release" flatten="true">
<fileset>
<include name="pubinfo/*.nuspec"/>
</fileset>
<filterchain>
<replacetokens begintoken="%" endtoken="%">
<token key="VERSION" value="${release.version}"/>
</replacetokens>
</filterchain>
</copy>
<foreach item="File" property="filename">
<in>
<items>
<include name="release/*.nuspec"/>
</items>
</in>
<do>
<exec program="NuGet">
<arg value="Pack"/>
<arg value="${filename}"/>
<arg value="-OutputDirectory"/>
<arg value="release"/>
</exec>
</do>
</foreach>
<call target="cleanup-after-release"/>
</target>
<target name="cleanup-after-release">
<delete dir="buildtmp" if="${directory::exists('buildtmp')}"/>
</target>
<!-- ================ Publication ================ -->
<target name="publish">
<call target="publish-NuGet"/>
</target>
<target name="publish-NuGet">
<exec program="NuGet" workingdir="release">
<arg value="push"/>
<arg value="*.nupkg"/>
</exec>
</target>
</project>