PageRenderTime 54ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/Passive.build

https://github.com/Talljoe/Passive
Bazel | 248 lines | 225 code | 23 blank | 0 comment | 0 complexity | 0db9b540ff9a59408b34d872d1040fc9 MD5 | raw file
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!--EXTERNAL_PROPERTIES: LOCAL_PACKAGE_PATH;release.version-->
  3. <project name="Passive" default="all">
  4. <loadtasks assembly="tools/gitnub/Tall.Gitnub.Nant.dll" />
  5. <property name="packages.source.local"
  6. value="${environment::get-variable('LOCAL_PACKAGE_SOURCE')}"
  7. if="${environment::variable-exists('LOCAL_PACKAGE_SOURCE')}"
  8. overwrite="false" />
  9. <property name="project.path" value="${project::get-base-directory()}" />
  10. <property name="asminfo.filepath" value="${project.path}/Passive/AssemblyInfo.cs" />
  11. <property name="dist.path" value="${project.path}/dist"/>
  12. <property name="build.path" value="${project.path}/build"/>
  13. <property name="tests.base.path" value="${build.path}/tests" />
  14. <property name="build.debug" value="PDBOnly" overwrite="false" />
  15. <property name="build.defines" value="" overwrite="false" />
  16. <property name="build.optimize" value="true" overwrite="false" />
  17. <property name="tools.git.path" value="${project.path}/tools/git" />
  18. <property name="tools.nuget.path" value="${project.path}/tools/nuget" />
  19. <property name="tools.github-upload.path" value="${project.path}/tools/github-upload"/>
  20. <property name="tools.xunit.path" value="${project.path}/tools/xunit"/>
  21. <property name="build.version"
  22. value="${version.major}.${version.minor}.${version.revision}.${version.build}"
  23. dynamic="true"/>
  24. <property name="build.assemblyversion" value="${version.major}.${version.minor}.0.0" dynamic="true"/>
  25. <property name="github.user" value="${git::readconfig('github.user')}" />
  26. <property name="github.token" value="${git::readconfig('github.token')}" />
  27. <property name="tests.configurations" value="sqlce;sqlexpress" overwrite="false" />
  28. <property name="tests.config.name" value="sqlce" overwrite="false" />
  29. <target name="passive" depends="init create-assembly-info">
  30. <csc noconfig="true"
  31. warnaserror="true"
  32. target="library"
  33. debug="${build.debug}"
  34. optimize="${build.optimize}"
  35. define="${build.defines}"
  36. output="${build.path}/Passive.dll"
  37. doc="${build.path}/Passive.xml"
  38. keyfile="Passive.snk" >
  39. <sources>
  40. <include name="${asminfo.filepath}"/>
  41. <include name="Passive/**/*.cs"/>
  42. </sources>
  43. <references>
  44. <include name="mscorlib.dll"/>
  45. <include name="Microsoft.CSharp.dll"/>
  46. <include name="System.dll"/>
  47. <include name="System.Core.dll"/>
  48. <include name="System.Configuration.dll"/>
  49. <include name="System.Data.dll"/>
  50. </references>
  51. </csc>
  52. </target>
  53. <target name="compile-tests" depends="passive">
  54. <patternset id="test-dependencies">
  55. <include name="${build.path}/Passive.dll" />
  56. <include name="${project.path}/packages/Rx-Interactive.*/lib/Net4/System.Interactive.dll"/>
  57. <include name="${project.path}/packages/Rx-AsyncLinq.*/lib/net4/System.Linq.Async.dll"/>
  58. <include name="${project.path}/packages/Rx-Core.*/lib/net4/System.CoreEx.dll"/>
  59. <include name="${project.path}/packages/xunit.*/lib/xunit.dll"/>
  60. <include name="${project.path}/packages/xunit.extensions.*/lib/xunit.extensions.dll"/>
  61. <include name="${project.path}/packages/SqlServerCompact.*/lib/System.Data.SqlServerCe.dll"/>
  62. <include name="${project.path}/packages/SpecFlow.*/lib/net35/TechTalk.SpecFlow.dll"/>
  63. <include name="${project.path}/packages/FluentAssertions.*/lib/.NetFramework 4.0\FluentAssertions.dll"/>
  64. </patternset>
  65. <csc noconfig="true"
  66. warnaserror="true"
  67. target="library"
  68. debug="true"
  69. output="${tests.path}/Passive.Test.dll">
  70. <sources>
  71. <include name="Passive.Test/**/*.cs" />
  72. </sources>
  73. <references>
  74. <include name="mscorlib.dll"/>
  75. <include name="Microsoft.CSharp.dll"/>
  76. <include name="System.dll"/>
  77. <include name="System.Core.dll"/>
  78. <include name="System.Configuration.dll"/>
  79. <include name="System.Data.dll"/>
  80. <patternset refid="test-dependencies" />
  81. </references>
  82. </csc>
  83. <copy todir="${tests.path}" flatten="true">
  84. <fileset>
  85. <patternset refid="test-dependencies" />
  86. </fileset>
  87. </copy>
  88. <copy file="Passive.Test/${tests.config.name}.config" tofile="${tests.path}/Passive.Test.dll.config" />
  89. <copy todir="${tests.path}/Data" flatten="true">
  90. <fileset>
  91. <include name="Passive.Test/Data/*" />
  92. </fileset>
  93. </copy>
  94. </target>
  95. <target name="test">
  96. <foreach item="String" in="${tests.configurations}" delim=";" property="tests.config.name">
  97. <property name="tests.path" value="${tests.base.path}/${tests.config.name}" />
  98. <call target="test-core" />
  99. </foreach>
  100. </target>
  101. <target name="test-core" depends="compile-tests">
  102. <exec program="${tools.xunit.path}/xunit.console.clr4.exe"
  103. workingdir="${tests.path}"
  104. commandline="${tests.path}/Passive.Test.dll /silent /html ${tests.path}/results.html"
  105. failonerror="true" />
  106. </target>
  107. <target name="all" depends="passive test" />
  108. <target name="dist" depends="rebuild build-nuget-package build-dist-zip" />
  109. <target name="rebuild" depends="clean build" />
  110. <target name="build" depends="init all" />
  111. <target name="check-publish-branch">
  112. <property name="branch.name" value="master" />
  113. <fail message="Must be on branch '${branch.name}' to publish. Currently on '${git::getbranch()}.'" if="${git::getbranch() != branch.name}" />
  114. </target>
  115. <target name="publish" depends="check-publish-branch dist get-git-revision">
  116. <exec program="${tools.nuget.path}\nuget.exe" commandline="push ${dist.path}\Passive.${build.version}.nupkg" />
  117. <github-addfile filename="${dist.path}\Passive.${build.version}.nupkg"
  118. description="Passive Nuget package: v${build.version}"
  119. username="${github.user}"
  120. usertoken="${github.token}"
  121. repository="Talljoe/Passive" />
  122. <github-addfile filename="${dist.path}\Passive.${build.version}.zip"
  123. description="Passive binaries: v${build.version}"
  124. username="${github.user}"
  125. usertoken="${github.token}"
  126. repository="Talljoe/Passive" />
  127. </target>
  128. <target name="clean">
  129. <delete dir="${dist.path}" />
  130. <delete dir="${build.path}" />
  131. </target>
  132. <target name="init" depends="get-git-revision">
  133. <mkdir dir="${dist.path}" />
  134. <mkdir dir="${build.path}" />
  135. </target>
  136. <target name="create-assembly-info" depends="get-git-revision">
  137. <echo message="Build number: ${build.version}" />
  138. <asminfo output="${asminfo.filepath}" language="CSharp">
  139. <imports>
  140. <import namespace="System"/>
  141. <import namespace="System.Reflection"/>
  142. <import namespace="System.Runtime.InteropServices"/>
  143. </imports>
  144. <attributes>
  145. <attribute type="AssemblyProductAttribute" value="Passive: A 'Dynamic' Data-Access Framework" />
  146. <attribute type="AssemblyCompanyAttribute" value="Tall Ambitions LLC" />
  147. <attribute type="AssemblyCopyrightAttribute" value="Copyright © 2011 Joe Wasson, Rob Conery, and contributors" />
  148. <attribute type="AssemblyVersionAttribute" value="${build.assemblyversion}" />
  149. <attribute type="AssemblyFileVersionAttribute" value="${build.version}" />
  150. <attribute type="ComVisibleAttribute" value="false" />
  151. <attribute type="CLSCompliantAttribute" value="true" />
  152. </attributes>
  153. </asminfo>
  154. </target>
  155. <target name="build-nuget-package" depends="build">
  156. <xmlpoke file="Passive.nuspec"
  157. xpath="//package/nu:metadata/nu:version"
  158. value="${build.version}">
  159. <namespaces>
  160. <namespace prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
  161. <namespace prefix="xsd" uri="http://www.w3.org/2001/XMLSchema" />
  162. <namespace prefix="nu" uri="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" />
  163. </namespaces>
  164. </xmlpoke>
  165. <exec program="${tools.nuget.path}/nuget.exe"
  166. commandline="pack Passive.nuspec /OutputDirectory ${dist.path} /Verbose" />
  167. <if test="${property::exists('packages.source.local')}">
  168. <copy todir="${packages.source.local}" unless="${packages.source.local == ''}" flatten="true">
  169. <fileset>
  170. <include name="${dist.path}/*.nupkg" />
  171. </fileset>
  172. </copy>
  173. </if>
  174. </target>
  175. <target name="get-git-revision">
  176. <property name="temp.revision.file" value="RevisionNr.tmp" />
  177. <exec program="${tools.git.path}/git.exe"
  178. commandline="describe --long"
  179. failonerror="true"
  180. output="${temp.revision.file}" />
  181. <loadfile file="${temp.revision.file}" property="actual.git.revision" />
  182. <regex pattern="(?'gitmajor'\d+)\.(?'gitminor'\d+)\.(?'gitlastrevision'\d+)\.(\d+)-(?'gitrevisionnumber'\d+)-.*"
  183. input="${actual.git.revision}" />
  184. <xmlpeek file="Passive.nuspec"
  185. xpath="//package/nu:metadata/nu:version"
  186. property="actual.nuspec.revision">
  187. <namespaces>
  188. <namespace prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
  189. <namespace prefix="xsd" uri="http://www.w3.org/2001/XMLSchema" />
  190. <namespace prefix="nu" uri="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" />
  191. </namespaces>
  192. </xmlpeek>
  193. <regex pattern="(?'nuspecmajor'\d+)\.(?'nuspecminor'\d+)\.(?'nuspecrevisionnumber'\d+)\.(?'nuspecbuild'\d+)"
  194. input="${actual.nuspec.revision}" />
  195. <property name="version.major" value="${gitmajor}" overwrite="true" />
  196. <property name="version.minor" value="${gitminor}" overwrite="true" />
  197. <property name="version.revision" value="${int::parse(gitlastrevision) + int::parse(gitrevisionnumber)}" overwrite="true" />
  198. <property name="sameversion" value="${nuspecmajor == version.major and nuspecminor == version.minor and nuspecrevisionnumber == version.revision}" />
  199. <property name="version.build" value="0" overwrite="true" unless="${sameversion}" />
  200. <property name="version.build" value="${int::parse(nuspecbuild) + 1}" overwrite="true" if="${sameversion}" />
  201. <delete file="${temp.revision.file}" failonerror="false" />
  202. </target>
  203. <target name="tag" depends="get-git-revision">
  204. <fail if="${release.version == ''}"
  205. message="Property 'release.version' is not set." />
  206. <regex pattern="(?'relmajor'\d+)\.(?'relminor'\d+)\.(?'relbuild'\d+)\.(?'relrevision'\d+)"
  207. input="${release.version}" />
  208. <fail message="Version number ${release.version} should be greater than the current version number ${build.version}."
  209. unless="${relmajor > version.major or
  210. (relmajor == version.major and
  211. (relminor > version.minor or
  212. (relminor == version.minor and relbuild > version.build)))}" />
  213. <echo message="Tagging release with version ${release.version}" />
  214. <exec program="${tools.git.path}/git.exe"
  215. commandline='tag -a ${release.version} -m "Release ${release.version}"' />
  216. <call target="get-git-revision" />
  217. </target>
  218. <target name="build-dist-zip" depends="build">
  219. <zip zipfile="${dist.path}/Passive.${build.version}.zip">
  220. <fileset basedir="${build.path}">
  221. <include name="*" />
  222. </fileset>
  223. </zip>
  224. </target>
  225. </project>