-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathdbdeploy.build
executable file
·271 lines (239 loc) · 11.5 KB
/
dbdeploy.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
<?xml version="1.0"?>
<project name="dbdeploy" default="all" basedir="." xmlns="http://nant.sf.net/release/0.85/nant.xsd">
<property name="configuration" value="Build"/>
<property name="src.dir" value="src"/>
<property name="lib.dir" value="lib" />
<property name="config.dir" value="config" />
<property name="build.dir" value="build" />
<property name="test.dir" value="${build.dir}/"/>
<property name="dist.dir" value="dist" />
<property name="nantcontrib.assembly" value="tools\nant\contrib\NAnt.Contrib.Tasks.dll" />
<property name="ilmerge.exe" value="Tools\ILMerge.exe" />
<!-- DEFAULT CCNET PROPERTIES, to override: create a copy of local.properties.template, rename it local.properties, and modify the values as needed-->
<property name="sql.dir" value="${path::get-full-path('db')}" />
<property name="sql.server" value=".\SQLEXPRESS" />
<property name="sql.db" value="DBDEPLOY" />
<property name="sql.username" value="DBDeployUser"/>
<property name="sql.password" value="Password01"/>
<include buildfile="local.properties" if="${file::exists('local.properties')}" />
<target name="all" depends="clean, db, compile, test, dist" />
<target name="init">
<mkdir dir="${dist.dir}" />
<mkdir dir="${build.dir}" />
</target>
<target name="compile" depends="init">
<loadtasks assembly="${nantcontrib.assembly}" />
<msbuild project="${src.dir}/dbdeploy.net.sln">
<property name="Configuration" value="${configuration}" />
</msbuild>
<copy file="${src.dir}/dbproviders.xml" todir="${build.dir}" overwrite="true" />
<copy file="${lib.dir}/NAnt.Core.dll" todir="${build.dir}" overwrite="true" />
<copy file="${config.dir}/App.config.template" tofile="${build.dir}/Test.Net.Sf.Dbdeploy.dll.config" overwrite="true">
<filterchain>
<replacetokens>
<token key="DB_SERVER" value="${sql.server}" />
<token key="DB_NAME" value="${sql.db}" />
<token key="DB_USER_NAME" value="${sql.username}" />
<token key="DB_USER_PWD" value="${sql.password}" />
</replacetokens>
</filterchain>
</copy>
</target>
<target name="clean" description="Delete compiled classes etc">
<delete dir="${build.dir}" />
<delete dir="${dist.dir}" />
</target>
<target name="test">
<loadtasks assembly="${lib.dir}/nunit.framework.dll" />
<nunit2>
<formatter type="Xml" usefile="true" extension=".xml" outputdir="${test.dir}" />
<test assemblyname="${test.dir}/Test.Net.Sf.Dbdeploy.dll" appconfig="${test.dir}/Test.Net.Sf.Dbdeploy.dll.config">
<categories>
<exclude name="DbIntegration" />
</categories>
</test>
</nunit2>
</target>
<target name="test-all">
<loadtasks assembly="${lib.dir}/nunit.framework.dll" />
<nunit2>
<formatter type="Xml" usefile="true" extension=".xml" outputdir="${test.dir}" />
<formatter type="Plain" />
<test assemblyname="${test.dir}/Test.Net.Sf.Dbdeploy.dll" appconfig="${test.dir}/Test.Net.Sf.Dbdeploy.dll.config"/>
</nunit2>
</target>
<target name="dist">
<mkdir dir="${build.dir}/combined" />
<ilmerge outputfile="${build.dir}/combined/Net.Sf.Dbdeploy.dll" program="${ilmerge.exe}" primary="${build.dir}/Net.Sf.Dbdeploy.dll">
<assemblies>
<include name="${build.dir}/NVelocity.dll" />
</assemblies>
</ilmerge>
<ilmerge outputfile="${build.dir}/combined/dbdeploy.exe" program="${ilmerge.exe}" primary="${build.dir}/dbdeploy.exe">
<assemblies>
<include name="${build.dir}/NDesk.Options.dll" />
</assemblies>
</ilmerge>
<zip zipfile="${dist.dir}/dbdeploy.net.zip">
<fileset basedir="${build.dir}" prefix="bin/">
<include name="dbproviders.xml" />
<include name="MSBuild.Dbdeploy.Task.dll" />
<include name="Dbdeploy.NAnt.dll" />
<include name="Dbdeploy.Powershell.dll" />
<include name="NAnt.Core.dll" />
<include name="dbdeploy.exe.config" />
</fileset>
<fileset basedir="${build.dir}/combined" prefix="bin/">
<include name="dbdeploy.exe" />
<include name="Net.Sf.Dbdeploy.dll" />
</fileset>
<fileset basedir="${build.dir}/Resources" prefix="bin/Resources/">
<include name="**/*.vm" />
</fileset>
<fileset basedir="scripts" prefix="scripts/">
<include name="**/*" />
</fileset>
<fileset basedir="example_scripts" prefix="example/">
<include name="**/*" />
</fileset>
</zip>
</target>
<target name="db">
<loadtasks assembly="tools\nant\contrib\NAnt.Contrib.Tasks.dll"/>
<property name="sql.file" value="db\create.database.sql" />
<copy file="${sql.file}.template" tofile="${sql.file}" overwrite="true">
<filterchain>
<replacetokens>
<token key="DB_DIR" value="${sql.dir}" />
<token key="DB_NAME" value="${sql.db}" />
<token key="DB_USER_NAME" value="${sql.username}" />
<token key="DB_USER_PWD" value="${sql.password}" />
</replacetokens>
</filterchain>
</copy>
<sql connstring="Provider=sqloledb;Data Source=${sql.server};Initial Catalog=master;Integrated Security=SSPI"
source="${sql.file}" output="${sql.file}.output.txt"
delimiter="GO" delimstyle="Line"
transaction="false" batch="false" print="true" />
</target>
<script language="C#" prefix="custom" >
<references>
<include name="System.dll" />
<include name="NAnt.Core.dll" />
</references>
<imports>
<import namespace="System" />
<import namespace="System.Collections" />
<import namespace="System.Collections.Specialized" />
<import namespace="NAnt.Core.Types" />
<import namespace="NAnt.Core.Util" />
<import namespace="NAnt.Core.Tasks" />
</imports>
<code>
<![CDATA[
[TaskName("ilmerge")]
public class ILMergeTask : ExternalProgramBase {
private FileSet m_assemblies;
private string m_logFile;
private string m_outputFile;
private string m_primaryFile;
[TaskAttribute("program", Required = true)]
[StringValidator(AllowEmpty = false)]
public override string ExeName
{
get { return base.ExeName; }
set { base.ExeName = value; }
}
public override string ProgramArguments
{
get { return string.Empty; }
}
[BuildElement("assemblies", Required=true)]
public virtual FileSet InputAssemblies
{
get
{
return this.m_assemblies;
}
set
{
this.m_assemblies = value;
}
}
[TaskAttribute("logfile")]
public virtual string LogFile
{
get
{
if (this.m_logFile == null)
{
return null;
}
return this.Project.GetFullPath(this.m_logFile);
}
set
{
this.m_logFile = StringUtils.ConvertEmptyToNull(value);
}
}
[TaskAttribute("primary", Required=true), StringValidator(AllowEmpty=false)]
public virtual string PrimaryFile
{
get
{
if (this.m_primaryFile == null)
{
return null;
}
return this.Project.GetFullPath(this.m_primaryFile);
}
set
{
this.m_primaryFile = StringUtils.ConvertEmptyToNull(value);
}
}
[TaskAttribute("outputfile", Required=true), StringValidator(AllowEmpty=false)]
public virtual string OutputFile
{
get
{
if (this.m_outputFile == null)
{
return null;
}
return this.Project.GetFullPath(this.m_outputFile);
}
set
{
this.m_outputFile = StringUtils.ConvertEmptyToNull(value);
}
}
protected override void ExecuteTask()
{
try
{
Log(Level.Info, "Executing ILMerge.exe");
Log(Level.Info, string.Format("/out:\"{0}\"", m_outputFile));
Log(Level.Info, string.Format("/log:\"{0}\"", m_logFile));
Arguments.Add(new Argument(string.Format("/out:\"{0}\"", m_outputFile)));
Log(Level.Info, string.Format("assembly[{0}]: {1}", "primary", m_primaryFile));
Arguments.Add(new Argument(string.Format("\"{0}\"", m_primaryFile)));
for (int i = 0; i < m_assemblies.FileNames.Count; i++)
{
Log(Level.Info, string.Format("assembly[{0}]: {1}", i, m_assemblies.FileNames[i]));
Arguments.Add(new Argument(string.Format("\"{0}\"", m_assemblies.FileNames[i])));
}
Arguments.Add(new Argument(string.Format("/log:\"{0}\"", m_logFile)));
base.FailOnError = false;
base.ExecuteTask();
}
catch (Exception ex)
{
throw new BuildException(string.Format("Error executing ILMerge {0}", "test"), Location, ex);
}
}
}
]]>
</code>
</script>
</project>