default.build 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <project name="migrator" default="build" xmlns="http://nant.sf.net/release/0.85/nant.xsd">
  3. <property name="dotnet" value="true" if="${framework::get-target-framework() == 'net-2.0' or framework::get-target-framework() == 'net-3.5'}"/>
  4. <property name="mono" value="true" if="${framework::get-target-framework() == 'mono-2.0'}"/>
  5. <property name="defines" value="DOTNET2" if="${property::exists('dotnet')}" />
  6. <property name="defines" value="MONO2" if="${property::exists('mono')}" />
  7. <property name="version" value="0.8"/>
  8. <property name="debug" value="true" />
  9. <!-- Paths to various parts of the build -->
  10. <property name="dir.bin" value="build" />
  11. <property name="dir.lib" value="lib" />
  12. <property name="dir.results" value="results"/>
  13. <property name="dir.zip" value="${dir.bin}/zip" />
  14. <property name="dir.src" value="src"/>
  15. <property name="dir.config" value="${dir.src}/config" />
  16. <property name="dir.tests" value="${dir.src}/Migrator.Tests" />
  17. <property name="dir.msbuild" value="${dir.src}/Migrator.MSBuild" />
  18. <property name="dir.nant" value="${dir.src}/Migrator.NAnt" />
  19. <property name="dir.framework" value="${dir.src}/Migrator.Framework" />
  20. <property name="dir.providers" value="${dir.src}/Migrator.Providers" />
  21. <property name="dir.core" value="${dir.src}/Migrator" />
  22. <property name="dir.console" value="${dir.src}/Migrator.Console" />
  23. <property name="dir.tools.ncover" value="${dir.lib}/NCover" />
  24. <property name="dir.tools.nunit" value="${dir.lib}/NUnit" />
  25. <property name="dir.lib.postgre" value="${dir.lib}/Npgsql/${framework::get-target-framework()}" />
  26. <property name="dir.keyfile" value="${dir.src}/MigratorDotNet.snk" />
  27. <property name="test.project.name" value="Migrator.Tests"/>
  28. <!-- Test related properties -->
  29. <!-- To exclude tests, provide a comma separated set of exclude categories in your local.properties e.g. Oracle,SqlServer,Postgre -->
  30. <property name="tests.exclude" value=""/>
  31. <property name="tests.app.config" value="${dir.config}/app.config"/>
  32. <!-- Overrideable. Add your own values to a file called local.properties to have them override any above properties -->
  33. <include buildfile="local.properties" failonerror="false"/>
  34. <!-- load the NCover NAnt tasks -->
  35. <loadtasks assembly="${dir.tools.ncover}/Explorer/NCoverExplorer.NAntTasks.dll" />
  36. <!--
  37. Once we setup to build from sln, we can specify build config to target
  38. which is ideal to output release assemblies over debug. the debug, release
  39. targets are not used at the moment
  40. <target name="debug">
  41. <property name="build.config" value="Debug" />
  42. <call target="build" />
  43. </target>
  44. <target name="release">
  45. <property name="build.config" value="Release" />
  46. <call target="build.common" />
  47. </target>
  48. -->
  49. <target name="build" description="Builds the app" depends="prepare">
  50. <csc target="library" output="${dir.bin}/Migrator.Framework.dll" define="${defines}" debug="${debug}" keyfile="${dir.keyfile}">
  51. <sources>
  52. <include name="${dir.config}/AssemblyInfo.cs" />
  53. <include name="${dir.framework}/**/*.cs" />
  54. </sources>
  55. <references>
  56. <include name="System.dll" />
  57. <include name="System.Data.dll" />
  58. </references>
  59. </csc>
  60. <csc target="library" output="${dir.bin}/Migrator.Providers.dll" define="${defines}" debug="${debug}" keyfile="${dir.keyfile}">
  61. <sources>
  62. <include name="${dir.config}/AssemblyInfo.cs" />
  63. <include name="${dir.providers}/**/*.cs" />
  64. </sources>
  65. <references>
  66. <include name="System.dll" />
  67. <include name="System.Data.dll" />
  68. <include name="Mono.Data.Sqlite.dll" if="${property::exists('mono')}"/>
  69. <include name="${dir.bin}/System.Data.SQLite.DLL" if="${property::exists('dotnet')}"/>
  70. <include name="${dir.bin}/Migrator.Framework.dll" />
  71. <include name="${dir.bin}/MySql.Data.dll" />
  72. <include name="${dir.bin}/Npgsql.dll" />
  73. <include name="${dir.lib}/Oracle.DataAccess.dll" />
  74. <include name="${dir.lib}/System.Data.SqlServerCe.dll" />
  75. </references>
  76. </csc>
  77. <csc target="library" output="${dir.bin}/Migrator.dll" define="${defines}" debug="${debug}" keyfile="${dir.keyfile}">
  78. <sources>
  79. <include name="${dir.config}/AssemblyInfo.cs" />
  80. <include name="${dir.core}/**/*.cs" />
  81. </sources>
  82. <references>
  83. <include name="System.dll" />
  84. <include name="System.Data.dll" />
  85. <include name="System.Configuration.dll" />
  86. <include name="${dir.bin}/Migrator.Framework.dll" />
  87. <include name="${dir.bin}/Migrator.Providers.dll" />
  88. </references>
  89. </csc>
  90. <csc target="library" output="${dir.bin}/Migrator.NAnt.dll" define="${defines}" debug="${debug}">
  91. <sources>
  92. <include name="${dir.config}/AssemblyInfo.cs" />
  93. <include name="${dir.nant}/**/*.cs" />
  94. </sources>
  95. <references>
  96. <include name="System.dll" />
  97. <include name="${dir.bin}/NAnt.Core.dll" />
  98. <include name="${dir.bin}/Migrator.Framework.dll" />
  99. <include name="${dir.bin}/Migrator.dll" />
  100. </references>
  101. </csc>
  102. <csc target="library" output="${dir.bin}/Migrator.MSBuild.dll" define="${defines}" debug="${debug}" if="${framework::get-target-framework() == 'net-2.0'}" keyfile="${dir.keyfile}">
  103. <sources>
  104. <include name="${dir.config}/AssemblyInfo.cs" />
  105. <include name="${dir.msbuild}/**/*.cs" />
  106. </sources>
  107. <references>
  108. <include name="System.dll" />
  109. <include name="Microsoft.Build.Framework.dll" />
  110. <include name="Microsoft.Build.Utilities.dll" />
  111. <include name="${dir.bin}/Migrator.Framework.dll" />
  112. <include name="${dir.bin}/Migrator.dll" />
  113. </references>
  114. </csc>
  115. <csc target="exe" output="${dir.bin}/Migrator.Console.exe" define="${defines}" debug="${debug}" keyfile="${dir.keyfile}">
  116. <sources>
  117. <include name="${dir.config}/AssemblyInfo.cs" />
  118. <include name="${dir.console}/**/*.cs" />
  119. </sources>
  120. <references>
  121. <include name="System.dll" />
  122. <include name="${dir.bin}/Migrator.Framework.dll" />
  123. <include name="${dir.bin}/Migrator.dll" />
  124. </references>
  125. </csc>
  126. </target>
  127. <target name="rebuild" description="Rebuilds the app from scratch" depends="clean, build" />
  128. <target name="build.tests" description="Builds the tests" depends="build, prepare.tests">
  129. <copy file="${tests.app.config}" tofile="${dir.bin}/${test.project.name}.dll.config" />
  130. <csc target="library" output="${dir.bin}/${test.project.name}.dll" define="${defines}" debug="${debug}">
  131. <sources>
  132. <include name="${dir.tests}/**/*.cs" />
  133. </sources>
  134. <references>
  135. <include name="System.dll" />
  136. <include name="System.Data.dll" />
  137. <include name="System.Configuration.dll" />
  138. <include name="${dir.lib}/System.Data.SqlServerCe.dll" />
  139. <include name="${dir.bin}/Migrator.Framework.dll" />
  140. <include name="${dir.bin}/Migrator.dll" />
  141. <include name="${dir.bin}/Migrator.Providers.dll" />
  142. <include name="${dir.tools.nunit}/nunit.mocks.dll" />
  143. <include name="${dir.tools.nunit}/nunit.framework.dll" />
  144. </references>
  145. </csc>
  146. </target>
  147. <target name="prepare">
  148. <mkdir dir="${dir.bin}" />
  149. <copy file="${dir.msbuild}/Migrator.Targets" todir="${dir.bin}" />
  150. <copy todir="${dir.bin}" flatten="true">
  151. <fileset>
  152. <include name="${dir.lib}/NAnt.Core.dll" />
  153. <include name="${dir.lib}/log4net.dll" />
  154. <include name="${dir.lib}/MySql.Data.dll" />
  155. <include name="${dir.lib}/System.Data.SQLite.DLL" />
  156. <include name="${dir.lib.postgre}/Npgsql.dll" />
  157. <include name="${dir.lib.postgre}/Mono.Security.dll" />
  158. <include name="${dir.lib}/Oracle.DataAccess.dll" />
  159. <include name="${dir.lib}/System.Data.SqlServerCe.dll" />
  160. </fileset>
  161. </copy>
  162. </target>
  163. <target name="prepare.tests">
  164. <mkdir dir="${dir.bin}" />
  165. <mkdir dir="${dir.results}"/>
  166. <copy todir="${dir.bin}" flatten="true">
  167. <fileset>
  168. <include name="${dir.tools.nunit}/nunit.mocks.dll" />
  169. <include name="${dir.tools.nunit}/nunit.framework.dll" />
  170. </fileset>
  171. </copy>
  172. </target>
  173. <target name="clean" description="Sweep it yeah!">
  174. <delete dir="${dir.bin}"/>
  175. <delete dir="${dir.results}"/>
  176. </target>
  177. <target name="test" description="Run tests" depends="build.tests">
  178. <nunit2>
  179. <formatter type="Plain" />
  180. <test
  181. assemblyname="${dir.bin}/Migrator.Tests.dll"
  182. appconfig="${tests.app.config}">
  183. <categories>
  184. <exclude name="${tests.exclude}"/>
  185. </categories>
  186. </test>
  187. </nunit2>
  188. </target>
  189. <target name="test.coverage" description="Run the tests with code coverage. Only works on Windows/.NET" depends="build.tests">
  190. <ncover program="${dir.tools.ncover}/NCover.Console.exe"
  191. commandLineExe="${dir.tools.nunit}/nunit-console.exe"
  192. commandLineArgs="${dir.bin}/${test.project.name}.dll /exclude=${tests.exclude} /labels /nologo /noshadow"
  193. coverageFile="${dir.results}/coverage.xml"
  194. logFile="${dir.results}/coverage.log">
  195. <assemblies basedir="${dir.bin}">
  196. <include name="Migrator.*.dll" />
  197. <include name="Migrator.dll" />
  198. <exclude name="*.Tests.dll" />
  199. </assemblies>
  200. </ncover>
  201. <ncoverexplorer program="${dir.tools.ncover}/Explorer/NCoverExplorer.Console.exe"
  202. projectName="Migrator"
  203. outputDir="${dir.results}"
  204. satisfactoryCoverage="80"
  205. reportType="ModuleClassFunctionSummary"
  206. htmlReportName="CoverageSummary.html"
  207. showExcluded="True">
  208. <fileset>
  209. <include name="${dir.results}/coverage.xml" />
  210. </fileset>
  211. </ncoverexplorer>
  212. </target>
  213. <target name="zip" description="Creates a zip file of the entire project including examples, source and docs" depends="build">
  214. <mkdir dir="${dir.zip}" />
  215. <property name="zipcontainer" value="${dir.zip}/migratordotnet-${version}"/>
  216. <mkdir dir="${zipcontainer}" />
  217. <mkdir dir="${zipcontainer}/lib" />
  218. <copy todir="${zipcontainer}/lib">
  219. <fileset basedir="${dir.bin}">
  220. <include name="**/*" />
  221. </fileset>
  222. </copy>
  223. <copy todir="${zipcontainer}">
  224. <fileset>
  225. <include name="doc/**/*" />
  226. </fileset>
  227. </copy>
  228. <zip zipfile="migratordotnet-${version}.zip">
  229. <fileset basedir="${dir.zip}">
  230. <include name="**/*" />
  231. </fileset>
  232. </zip>
  233. <delete dir="${dir.zip}"/>
  234. </target>
  235. </project>