/Passive.build
Bazel | 248 lines | 225 code | 23 blank | 0 comment | 0 complexity | 0db9b540ff9a59408b34d872d1040fc9 MD5 | raw file
- <?xml version="1.0" encoding="utf-8"?>
- <!--EXTERNAL_PROPERTIES: LOCAL_PACKAGE_PATH;release.version-->
- <project name="Passive" default="all">
- <loadtasks assembly="tools/gitnub/Tall.Gitnub.Nant.dll" />
- <property name="packages.source.local"
- value="${environment::get-variable('LOCAL_PACKAGE_SOURCE')}"
- if="${environment::variable-exists('LOCAL_PACKAGE_SOURCE')}"
- overwrite="false" />
- <property name="project.path" value="${project::get-base-directory()}" />
- <property name="asminfo.filepath" value="${project.path}/Passive/AssemblyInfo.cs" />
- <property name="dist.path" value="${project.path}/dist"/>
- <property name="build.path" value="${project.path}/build"/>
- <property name="tests.base.path" value="${build.path}/tests" />
- <property name="build.debug" value="PDBOnly" overwrite="false" />
- <property name="build.defines" value="" overwrite="false" />
- <property name="build.optimize" value="true" overwrite="false" />
- <property name="tools.git.path" value="${project.path}/tools/git" />
- <property name="tools.nuget.path" value="${project.path}/tools/nuget" />
- <property name="tools.github-upload.path" value="${project.path}/tools/github-upload"/>
- <property name="tools.xunit.path" value="${project.path}/tools/xunit"/>
- <property name="build.version"
- value="${version.major}.${version.minor}.${version.revision}.${version.build}"
- dynamic="true"/>
- <property name="build.assemblyversion" value="${version.major}.${version.minor}.0.0" dynamic="true"/>
- <property name="github.user" value="${git::readconfig('github.user')}" />
- <property name="github.token" value="${git::readconfig('github.token')}" />
- <property name="tests.configurations" value="sqlce;sqlexpress" overwrite="false" />
- <property name="tests.config.name" value="sqlce" overwrite="false" />
- <target name="passive" depends="init create-assembly-info">
- <csc noconfig="true"
- warnaserror="true"
- target="library"
- debug="${build.debug}"
- optimize="${build.optimize}"
- define="${build.defines}"
- output="${build.path}/Passive.dll"
- doc="${build.path}/Passive.xml"
- keyfile="Passive.snk" >
- <sources>
- <include name="${asminfo.filepath}"/>
- <include name="Passive/**/*.cs"/>
- </sources>
- <references>
- <include name="mscorlib.dll"/>
- <include name="Microsoft.CSharp.dll"/>
- <include name="System.dll"/>
- <include name="System.Core.dll"/>
- <include name="System.Configuration.dll"/>
- <include name="System.Data.dll"/>
- </references>
- </csc>
- </target>
- <target name="compile-tests" depends="passive">
- <patternset id="test-dependencies">
- <include name="${build.path}/Passive.dll" />
- <include name="${project.path}/packages/Rx-Interactive.*/lib/Net4/System.Interactive.dll"/>
- <include name="${project.path}/packages/Rx-AsyncLinq.*/lib/net4/System.Linq.Async.dll"/>
- <include name="${project.path}/packages/Rx-Core.*/lib/net4/System.CoreEx.dll"/>
- <include name="${project.path}/packages/xunit.*/lib/xunit.dll"/>
- <include name="${project.path}/packages/xunit.extensions.*/lib/xunit.extensions.dll"/>
- <include name="${project.path}/packages/SqlServerCompact.*/lib/System.Data.SqlServerCe.dll"/>
- <include name="${project.path}/packages/SpecFlow.*/lib/net35/TechTalk.SpecFlow.dll"/>
- <include name="${project.path}/packages/FluentAssertions.*/lib/.NetFramework 4.0\FluentAssertions.dll"/>
- </patternset>
- <csc noconfig="true"
- warnaserror="true"
- target="library"
- debug="true"
- output="${tests.path}/Passive.Test.dll">
- <sources>
- <include name="Passive.Test/**/*.cs" />
- </sources>
- <references>
- <include name="mscorlib.dll"/>
- <include name="Microsoft.CSharp.dll"/>
- <include name="System.dll"/>
- <include name="System.Core.dll"/>
- <include name="System.Configuration.dll"/>
- <include name="System.Data.dll"/>
- <patternset refid="test-dependencies" />
- </references>
- </csc>
- <copy todir="${tests.path}" flatten="true">
- <fileset>
- <patternset refid="test-dependencies" />
- </fileset>
- </copy>
- <copy file="Passive.Test/${tests.config.name}.config" tofile="${tests.path}/Passive.Test.dll.config" />
- <copy todir="${tests.path}/Data" flatten="true">
- <fileset>
- <include name="Passive.Test/Data/*" />
- </fileset>
- </copy>
- </target>
- <target name="test">
- <foreach item="String" in="${tests.configurations}" delim=";" property="tests.config.name">
- <property name="tests.path" value="${tests.base.path}/${tests.config.name}" />
- <call target="test-core" />
- </foreach>
- </target>
- <target name="test-core" depends="compile-tests">
- <exec program="${tools.xunit.path}/xunit.console.clr4.exe"
- workingdir="${tests.path}"
- commandline="${tests.path}/Passive.Test.dll /silent /html ${tests.path}/results.html"
- failonerror="true" />
- </target>
- <target name="all" depends="passive test" />
- <target name="dist" depends="rebuild build-nuget-package build-dist-zip" />
- <target name="rebuild" depends="clean build" />
- <target name="build" depends="init all" />
- <target name="check-publish-branch">
- <property name="branch.name" value="master" />
- <fail message="Must be on branch '${branch.name}' to publish. Currently on '${git::getbranch()}.'" if="${git::getbranch() != branch.name}" />
- </target>
- <target name="publish" depends="check-publish-branch dist get-git-revision">
- <exec program="${tools.nuget.path}\nuget.exe" commandline="push ${dist.path}\Passive.${build.version}.nupkg" />
- <github-addfile filename="${dist.path}\Passive.${build.version}.nupkg"
- description="Passive Nuget package: v${build.version}"
- username="${github.user}"
- usertoken="${github.token}"
- repository="Talljoe/Passive" />
- <github-addfile filename="${dist.path}\Passive.${build.version}.zip"
- description="Passive binaries: v${build.version}"
- username="${github.user}"
- usertoken="${github.token}"
- repository="Talljoe/Passive" />
- </target>
- <target name="clean">
- <delete dir="${dist.path}" />
- <delete dir="${build.path}" />
- </target>
- <target name="init" depends="get-git-revision">
- <mkdir dir="${dist.path}" />
- <mkdir dir="${build.path}" />
- </target>
- <target name="create-assembly-info" depends="get-git-revision">
- <echo message="Build number: ${build.version}" />
- <asminfo output="${asminfo.filepath}" language="CSharp">
- <imports>
- <import namespace="System"/>
- <import namespace="System.Reflection"/>
- <import namespace="System.Runtime.InteropServices"/>
- </imports>
- <attributes>
- <attribute type="AssemblyProductAttribute" value="Passive: A 'Dynamic' Data-Access Framework" />
- <attribute type="AssemblyCompanyAttribute" value="Tall Ambitions LLC" />
- <attribute type="AssemblyCopyrightAttribute" value="Copyright © 2011 Joe Wasson, Rob Conery, and contributors" />
- <attribute type="AssemblyVersionAttribute" value="${build.assemblyversion}" />
- <attribute type="AssemblyFileVersionAttribute" value="${build.version}" />
- <attribute type="ComVisibleAttribute" value="false" />
- <attribute type="CLSCompliantAttribute" value="true" />
- </attributes>
- </asminfo>
- </target>
- <target name="build-nuget-package" depends="build">
- <xmlpoke file="Passive.nuspec"
- xpath="//package/nu:metadata/nu:version"
- value="${build.version}">
- <namespaces>
- <namespace prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
- <namespace prefix="xsd" uri="http://www.w3.org/2001/XMLSchema" />
- <namespace prefix="nu" uri="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" />
- </namespaces>
- </xmlpoke>
- <exec program="${tools.nuget.path}/nuget.exe"
- commandline="pack Passive.nuspec /OutputDirectory ${dist.path} /Verbose" />
- <if test="${property::exists('packages.source.local')}">
- <copy todir="${packages.source.local}" unless="${packages.source.local == ''}" flatten="true">
- <fileset>
- <include name="${dist.path}/*.nupkg" />
- </fileset>
- </copy>
- </if>
- </target>
- <target name="get-git-revision">
- <property name="temp.revision.file" value="RevisionNr.tmp" />
- <exec program="${tools.git.path}/git.exe"
- commandline="describe --long"
- failonerror="true"
- output="${temp.revision.file}" />
- <loadfile file="${temp.revision.file}" property="actual.git.revision" />
- <regex pattern="(?'gitmajor'\d+)\.(?'gitminor'\d+)\.(?'gitlastrevision'\d+)\.(\d+)-(?'gitrevisionnumber'\d+)-.*"
- input="${actual.git.revision}" />
- <xmlpeek file="Passive.nuspec"
- xpath="//package/nu:metadata/nu:version"
- property="actual.nuspec.revision">
- <namespaces>
- <namespace prefix="xsi" uri="http://www.w3.org/2001/XMLSchema-instance" />
- <namespace prefix="xsd" uri="http://www.w3.org/2001/XMLSchema" />
- <namespace prefix="nu" uri="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd" />
- </namespaces>
- </xmlpeek>
- <regex pattern="(?'nuspecmajor'\d+)\.(?'nuspecminor'\d+)\.(?'nuspecrevisionnumber'\d+)\.(?'nuspecbuild'\d+)"
- input="${actual.nuspec.revision}" />
- <property name="version.major" value="${gitmajor}" overwrite="true" />
- <property name="version.minor" value="${gitminor}" overwrite="true" />
- <property name="version.revision" value="${int::parse(gitlastrevision) + int::parse(gitrevisionnumber)}" overwrite="true" />
- <property name="sameversion" value="${nuspecmajor == version.major and nuspecminor == version.minor and nuspecrevisionnumber == version.revision}" />
- <property name="version.build" value="0" overwrite="true" unless="${sameversion}" />
- <property name="version.build" value="${int::parse(nuspecbuild) + 1}" overwrite="true" if="${sameversion}" />
- <delete file="${temp.revision.file}" failonerror="false" />
- </target>
- <target name="tag" depends="get-git-revision">
- <fail if="${release.version == ''}"
- message="Property 'release.version' is not set." />
- <regex pattern="(?'relmajor'\d+)\.(?'relminor'\d+)\.(?'relbuild'\d+)\.(?'relrevision'\d+)"
- input="${release.version}" />
- <fail message="Version number ${release.version} should be greater than the current version number ${build.version}."
- unless="${relmajor > version.major or
- (relmajor == version.major and
- (relminor > version.minor or
- (relminor == version.minor and relbuild > version.build)))}" />
- <echo message="Tagging release with version ${release.version}" />
- <exec program="${tools.git.path}/git.exe"
- commandline='tag -a ${release.version} -m "Release ${release.version}"' />
- <call target="get-git-revision" />
- </target>
- <target name="build-dist-zip" depends="build">
- <zip zipfile="${dist.path}/Passive.${build.version}.zip">
- <fileset basedir="${build.path}">
- <include name="*" />
- </fileset>
- </zip>
- </target>
- </project>