<?xml version="1.0" ?>
<project name="Spring.NET" default="test">
<!--
Main build targets:
===================

"test":
  builds debug builds for all projects for all available target platforms

"compile-build-<framework id>":
  builds all projects for a specific platform, e.g. compile-build-3.5 for net-3.5

"doc":
  builds the reference and sdk documentation

"package":
  builds all projects for all target platforms, builds docs and packages everything for distribution

Build properties that may be set:
=================================
"project.build.sign":
  values: bool: true|false
  signs all assemblies. Requires the key file $/Spring.Net.snk to be in place

"mstest.exe":
  value: string, fully-qualified location of mstest.exe, for example, C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\mstest.exe

"vs-net.mstest.bin.dir":
  value: string: location of mstest.exe, for example C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE

"package.version":
  values: string: a 3-part number xx.xx.xx
  set the package version

"test.integration.data":
  values: bool: true|false
  set this to true to run integration tests that access a database

"test.integration.ems":
  values: bool: true|false
  set this to true to run integration tests that access TIBCO EMS

"test.integration.nms":
  values: bool: true|false
  set this to true to run integration tests that access ActiveMQ

"test.full":
  values: bool: true|false
  set this to true to run all available tests (example solutions, integration tests, etc.)

"doc.sdk":
  values: bool: true|false
  set this to true to use NDoc to generate API documentation.  Note Spring ships with documentation generated using Document X!

Additional Remarks:
===================

*) Building Spring.Messaging.Ems
  if you want to build Spring.Messaging.Ems (Tibco EMS support), you need to copy tibco.ems.dll and tibco.ems.admin.dll into '/lib/net/2.0'

*) Building Spring.Testing.Microsoft
  if you want to build Spring.Testing.Microsoft (MSTest Support), you need to have VS MSTest support installed (mstest.exe)


Running Integration Tests:
==========================

*) Database Integration Tests
- you need to have an MSSQL 2005 Server instance installed and configured an alias "SPRINGQA" for this instance
- create a login "springqa" with password "springqa" and assign the 'db_sysadmin' role

on the commandline enable the "test.integration.data" flag, e.g.:
  nant test -f:spring.build -D:test.integration.data=true

*) TIBCO EMS Integration Tests
- You need to have an EMS instance running at the URL tcp://localhost:7222

on the commandline enable the "test.integration.ems" flag, e.g.:
  nant test -f:spring.build -D:test.integration.ems=true

*) ActiveMQ Inegration Tests

on the commandline enable the "test.integration.nms" flag, e.g.:
  nant test -f:spring.build -D:test.integration.nms=true



Commandline Examples:
=====================

*) to build the distribution package, copy the key file into $/Spring.Net.snk and execute
  nant clean package -f:spring.build -D:project.build.sign=true -D:package.version=1.3.0

*) to build a specific target platform
  nant compile-build-3.5

*) to build just debug builds for all available platforms and execute tests
  nant test

-->

<!--
  global DIAGNOSTICS setting, applied to EVERY instance of <copy> task via verbose="${copy-verbose}" attribute
  so as to be toggled in ONE place and affect ALL copy operations; leave FALSE except for debugging/troubleshooting the build
-->
  <property name="copy-verbose" value="true" />

  <!-- global project settings -->
  <property name="project.name" value="Spring.NET"/>
  <property name="project.name.full" value="Spring.NET Framework"/>
  <property name="spring.basedir" value="${project::get-base-directory()}"/>
  <property name="nuget.packages.dir" value="${environment::get-variable('HOMEPATH') + '\.nuget\packages'}"/>
  <property name="spring.nonredistdir" value="${spring.basedir}\..\..\nonredist"/>
  <property name="tool.dir" value="${project::get-base-directory()}\build-support\tools"/>
  <property name="nuget.exe" value="${tool.dir}\NuGet\NuGet.exe"/>
  
  <!--Support for Windows XP in other languages. In Portuguese, for example, is "c:\Arquivos de Programs"-->
  <property name="programfiles" value="C:\Program Files"/>
  <property name="programfilesx86" value="C:\Program Files (x86)"/>
  <property name="programfiles" value="${environment::get-variable('ProgramFiles')}" failonerror="false"/>
  <property name="programfilesx86" value="${environment::get-variable('ProgramFiles(x86)')}" failonerror="false"/>
  
  <!-- build SDK docs with NDoc -->
  <property name="doc.sdk" value="false"/>

  <!-- turn on all tests if test.full specified -->
  <property name="test.full" value="false" overwrite="false" />
  <property name="test.integration.data" value="${test.full}" overwrite="false" />
  <property name="test.integration.ems" value="${test.full}" overwrite="false" />
  <property name="test.integration.nms" value="${test.full}" overwrite="false" />

  <!--
      the line below is for the ccnet build box - see target set-user-overrides for how to change this to your machine values if necessary
      - or better check the registry key as shown above
   -->
  <!-- property name="vs-net.mstest.bin.dir" value="K:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE" if="${not property::exists('vs-net.mstest.bin.dir')}" / -->

  <!-- debug or release -->
  <property name="project.build.config" value="debug"/>
  <property name="project.build.package" value="false"/>
  <property name="project.build.sign" value="false" overwrite="false" />
  
  <property name="test.withcoverage" value="true" overwrite="false" />
  <!-- what coverage tool to use: ncover or opencover -->
  <property name="test.coverage.tool" value="opencover" overwrite="false" />

  <!-- import non-redistributables if available -->
  <!-- to build certain libraries (e.g. Spring.Messaging.Ems), 3rd party libraries are required
       that we are not allowed to redistribute -->
  <if test="${directory::exists(spring.nonredistdir)}">
    <echo message="Copying non-redistributables into source tree"/>
    <copy todir="${spring.basedir}" verbose="${copy-verbose}">
      <fileset basedir="${spring.nonredistdir}">
        <include name="**/*.*"/>
      </fileset>
    </copy>
  </if>

  <!-- Include spring helpers -->
  <include buildfile="${spring.basedir}/Spring.include"/>
  <include buildfile="${spring.basedir}/common-project.include"/>

  <property name="package.version" value="0.0.0" overwrite="false"/>
  <!-- change this to sync the sdk doc version generated -->
  <property name="package.version.docs" value="${package.version}" />
  <!-- make system environment variables available as NAnt properties -->

  <property name="package.buildincrement" value="000" overwrite="false"/>
  <call target="check-package.passedbuildincrement" />
  
  <sysinfo failonerror="false" />

  <property name="project.company" value="SpringSource"/>
  <property name="project.copyright" value="Copyright 2002-2018 Spring.NET Framework Team."/>

  <property name="key.file" value="Spring.Net.snk"/>
  <property name="project.year" value="2018"/>

  <!-- Targets that are always executed -->
  <call target="set-build-configuration"/>

  <!-- What packages to build -->
  <property name="build.allnamespaces" value="false"/>

  <if test="${not build.allnamespaces}">
    <call target="set-build-namespaces-release"/>
  </if>
  <if test="${build.allnamespaces}">
    <call target="set-build-namespaces-all"/>
  </if>

  <!-- no matter what, we can only use the last 3 digits of the passed-in build-increment value so ensure this is the case -->
  <target name="check-package.passedbuildincrement">
	  <if test="${property::exists('package.passedbuildincrement') and string::get-length(package.passedbuildincrement) > 3}">
		<property name="package.buildincrement" value="${string::substring(package.passedbuildincrement, string::get-length(package.passedbuildincrement) -3, 3)}" overwrite="true" />
	  </if>
  </target>
  
  <!-- call target="set-framework-configuration"/ -->
  <call target="set-user-overrides"/>

  <!-- Targets that check settings -->
  <target name="check-package-version">
    <fail message="A package version has not been specified." if="${not property::exists('package.version')}"/>
  </target>
  <target name="check-package-dir">
    <property name="package.dir" value="build\package" overwrite="false"/>
    <mkdir dir="${package.dir}"/>
  </target>
  <target name="check-current-package-dir">
    <fail message="The current package directory has not been specified."
          if="${not property::exists('current.package.dir')}"/>
    <mkdir dir="${current.package.dir}"/>
  </target>
  <target name="check-htmlhelp-compiler">
    <if test="${not property::exists('htmlhelp.compiler')}">
      <readregistry property="htmlhelp.workshop.installroot"
                    key="SOFTWARE\Microsoft\HTML Help Workshop\InstallDir" hive="CurrentUser"
                    failonerror="false"/>
      <if test="${property::exists('htmlhelp.workshop.installroot')}">
        <property name="htmlhelp.compiler" value="${htmlhelp.workshop.installroot}/hhc.exe"/>
      </if>
    </if>
    <if test="${not property::exists('htmlhelp.compiler')}">
      <sysinfo/>
      <property name="htmlhelp.compiler" value="${sys.os.folder.programfiles}/HTML Help Worshop/hhc.exe"/>
    </if>
  </target>
  <!-- Target for cleaning up the current package directory -->
  <target name="clean-current-package-dir" depends="check-current-package-dir"
          description="Cleans the current package directory">
    <echo message="Cleaning the ${current.package.dir} package directory."/>
    <delete dir="${current.package.dir}" if="${directory::exists(current.package.dir)}"/>
    <mkdir dir="${current.package.dir}"/>
  </target>

  <!-- Displays configuration info, usefull for working out why Spring.NET doesn't build -->
  <target name="display-setup" depends="check-htmlhelp-compiler">
    <!-- Mono 2.0 -->
    <if test="${framework::exists('mono-2.0')}">
      <property name="nant.settings.currentframework" value="mono-2.0"/>
      <call target="display-target-framework"/>
    </if>
    <if test="${not framework::exists('mono-2.0')}">
      <echo message="Mono 2.0 runtime is not available."/>
    </if>
    <!-- SSCLI 1.0 -->
    <if test="${framework::exists('sscli-1.0')}">
      <property name="nant.settings.currentframework" value="sscli-1.0"/>
      <call target="display-target-framework"/>
    </if>
    <if test="${not framework::exists('sscli-1.0')}">
      <echo message="SSCLI 1.0 runtime is not available."/>
    </if>
    <!-- HTML Help Compiler -->
    <echo message="htmlhelp.compiler: ${htmlhelp.compiler}"/>
  </target>

  <target name="display-target-framework">
    <echo message=""/>
    <echo message="----------------------------------------------------------"/>
    <echo message=" ${nant.settings.currentframework.description}"/>
    <echo message="----------------------------------------------------------"/>
    <echo message=""/>
    <echo message="framework : ${framework::get-target-framework()}"/>
    <echo message="description : ${framework::get-description(framework::get-target-framework())}"/>
    <if test="${framework::sdk-exists(framework::get-target-framework())}">
      <echo message="sdk directory : ${framework::get-sdk-directory(framework::get-target-framework())}"/>
    </if>
    <if test="${not framework::sdk-exists(framework::get-target-framework())}">
      <echo message="sdk directory : &lt;not configured/available>"/>
    </if>
    <echo message="framework directory : ${framework::get-framework-directory(framework::get-target-framework())}"/>
    <echo message="assembly directory : ${framework::get-assembly-directory(framework::get-target-framework())}"/>
    <echo message=""/>
  </target>


  <!-- Target for setting the package configuration -->
  <target name="set-package-configuration" depends="check-package-dir, check-package-version">
    <property name="current.package.dir" value="${package.dir}/${project::get-name()}"/>
    <!-- for docs packaging MLP -->
    <!--
    <property name="current.package.dir" value="l:/release/${project::get-name()}"/>
    -->


    <property name="doc.dir" value="${current.package.dir}/doc"/>
    <property name="sdkdoc.dir" value="${doc.dir}/sdk"/>
  </target>

  <!-- Target for compiling all build configurations for all runtime configurations -->
 <!-- <target name="compile-build-all" description="Compile all build configurations for all runtime configurations">
    <echo message="Compiling all build configurations for all runtime configurations."/>

    <call target="set-debug-build-configuration"/>
    <call target="compile-build"/>
-->
    <!-- make the release build, which requires Spring.Net.snk, only if making an distributable release -->
    <!--<if test="${property::exists('project.build.package') and project.build.package}">
      <call target="set-release-build-configuration"/>
      <call target="compile-build"/>
    </if>


  </target>
-->
  <!-- Target for compiling all runtime configurations in the current build configuration -->
  <!--
  <target name="compile-build" description="Compile current build configurations for all runtime configurations">
    <echo message="Compiling all framework versions for the ${current.build.config} build configuration."/>

    <call target="compile-build-3.5"/>
    <call target="compile-build-4.0"/>
    <call target="compile-build-4.5"/>
  
    <call target="compile-build-mono-2.0"/>

  </target>
-->

  <target name="restore-nuget-packages" description="Restores NuGet packages that solution(s) reference">

  	  <exec 
		  program="${nuget.exe}"
		  commandline="restore .nuget/packages.config -SolutionDirectory ${spring.basedir}" 
		  workingdir="${spring.basedir}"
		  failonerror="true" />
	  
      <foreach item="File" property="filename">
      <in>
        <items basedir="${spring.basedir}">
          <include name="*.sln" />
          <include name="examples/**/*.sln" />
          <exclude name="examples/**/Spring.EmsQuickStart/*" />
          <exclude name="examples/**/Spring.Examples.Pool/*" />
          <exclude name="examples/**/SpringAir/*" />
        </items>
      </in>
      <do>
        <property name="solutionfile" value="${filename}" />
		<exec program="${msbuild.exe}" verbose="true">
		  <arg value="${solutionfile}"/>
		  <arg line="/v:m" />
		  <arg line="/m" />
		  <arg line="/nr:false" />
		  <arg line="/t:Restore"/>
		</exec>
	</do>
    </foreach>

  </target>

  <target name="compile-build-4.5" description="Builds for .NET 4.5 if available">
    <call target="compile-net-4.5"/>
  </target>

  <target name="compile" description="Builds the current build configuration for the current target framework."
          depends="check-current-build-config">
    <call target="compile-net-4.5"/>
  </target>

  <target name="compile-test"> <!-- used as configurable template by all compile-{net|mono|netcf}-x.x targets -->
    <property name="lib.dir" value="${spring.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}"/>

    <foreach item="Folder" property="path">
	  <in>
	    <items>
		   <include name="${spring.basedir}/build/${current.build.config}/*Tests" />
		   <exclude name="${spring.basedir}/build/${current.build.config}/Spring.Messaging.Ems.Integration.Tests" unless="${test.integration.ems}" />
		   <exclude name="${spring.basedir}/build/${current.build.config}/Spring.Messaging.Nms.Integration.Tests" unless="${test.integration.nms}" />
		   <exclude name="${spring.basedir}/build/${current.build.config}/Spring.Services.Tests" /> <!-- TODO should fix -->
		   <exclude name="${spring.basedir}/build/${current.build.config}/Spring.Testing.Microsoft.Tests" /> <!-- TODO use dotnet test -->
		   <exclude name="${spring.basedir}/build/${current.build.config}/Spring.Web.Conversation.NHibernate5.Tests" /> <!-- TODO check SQLite -->
		</items>
	  </in>
      <do>
		<echo message="Running .NET Framework tests for ${path}" />
        <property name="test.bin.dir" value="${path}/net452" />
		<if test="${directory::exists(test.bin.dir) == false}">
          <property name="test.bin.dir" value="${path}/net461" />
		</if>
		
        <property name="test.assemblyname" value="${string::substring(path, string::last-index-of(path, '\') + 1, string::get-length(path) - string::last-index-of(path, '\') - 1)}" />
        <property name="test.assemblyfile" value="${test.assemblyname}.dll" />
        <property name="test.assemblyname.tocover" value="${string::substring(test.assemblyname,0,string::last-index-of(test.assemblyname, '.Tests') )}" />
        <call target="common.run-tests" />
      </do>
    </foreach>	
	
	<!-- run .NET Core separately for now -->
    <call target="compile-test-netcore" />
	
    <!-- build coverage summary -->
	<exec program="${tool.dir}/ncoverexplorer/ncoverexplorer.console.exe" workingdir="${current.bin.dir}" failonerror="false" if="${test.coverage.tool == 'ncover' and test.withcoverage}">
		<arg value="/xml:&quot;${current.bin.dir}/TestCoverageSummary.xml&quot;" />
		<arg value="/report:ModuleClassFunctionSummary" />
		<arg value="/sort:4" />
		<arg value="/minCoverage:80" />
		<arg value="/q" />
		<arg path="${current.bin.dir}/*-TestCoverage.xml" />
	</exec>

	<exec program="${tool.dir}\ReportGenerator\bin\ReportGenerator.exe" workingdir="${current.bin.dir}" verbose="true" if="${test.coverage.tool == 'opencover' and test.withcoverage}">
		<arg value="*-TestCoverage.xml" />
		<arg path="${current.bin.dir}\CoverageReport\Summary" />
	</exec>
  </target>

  <target name="compile-test-netcore">
    <foreach item="File" property="file">
	  <in>
	    <items>
		   <include name="${spring.basedir}/test/Spring/Spring.Core.Tests/Spring.Core.Tests.csproj" />
		   <include name="${spring.basedir}/test/Spring/Spring.Aop.Tests/Spring.Aop.Tests.csproj" />
		   <include name="${spring.basedir}/test/Spring/Spring.Data.Tests/Spring.Data.Tests.csproj" />
		   <include name="${spring.basedir}/test/Spring/Spring.Testing.NUnit.Tests/Spring.Testing.NUnit.Tests.csproj" />
		   <include name="${spring.basedir}/test/Spring/Spring.Data.NHibernate5.Integration.Tests/Spring.Data.NHibernate5.Integration.Tests.csproj" />
		   <include name="${spring.basedir}/test/Spring/Spring.Data.NHibernate5.Tests/Spring.Data.NHibernate5.Tests.csproj" />
		   <include name="${spring.basedir}/test/Spring/Spring.Scheduling.Quartz3.Tests/Spring.Scheduling.Quartz3.Tests.csproj" />
		</items>
	  </in>
      <do>
        <echo message="Running .NET Core tests for ${file}" />

        <exec program="dotnet" verbose="true">
          <arg line="test" />
          <arg line="/nodeReuse:false" />
          <arg line="-c ${current.build.config}" />
          <arg line="-f netcoreapp2.1" />
          <arg line="${file}" />
		</exec>
      </do>
    </foreach>	
  </target>
  
  <target name="compile-net-4.5" description="Builds .NET Framework 4.5 version"
        depends="set-net-4.5-runtime-configuration, check-spring-basedir, restore-nuget-packages">
	
	<property name="test.withcoverage" value="false" overwrite="true"/>
	
	<if test="${property::exists('mstest.exe')}">
		<property name="mstest.exe.current" value="${property::get-value('mstest.exe')}" />
		<!-- <property name="mstest.exe.current" value="${string::replace(property::get-value('mstest.exe'), 'Microsoft Visual Studio 10.0', 'Microsoft Visual Studio 9.0')}" /> -->
	</if>
	<if test="${property::exists('mstest.exe')}">
		<property name="vs-net.mstest.bin.dir.current" value="${property::get-value('vs-net.mstest.bin.dir')}" />
		<!-- <property name="vs-net.mstest.bin.dir.current" value="${string::replace(property::get-value('vs-net.mstest.bin.dir'), 'Microsoft Visual Studio 10.0', 'Microsoft Visual Studio 9.0')}" /> -->
	</if>
	
	<call target="copykeys" if="${project.build.sign}"/>
    <call target="common.generate-assemblyinfo"/>

    <property name="build-ems" value="false" overwrite="true" />
    <property name="build-nms" value="true" overwrite="true" />
    <property name="build-quartz" value="true" overwrite="true" />
    <property name="build-msmq" value="true" overwrite="true" />
    <property name="build-msmq-tests" value="true" overwrite="true" />
    <property name="build-velocity" value="true" overwrite="true" />
	
    <property name="lib.dir" value="${spring.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}"/>
	<if test="${nant.settings.currentframework == 'net-4.5'}">
		<property name="lib.dir" value="${spring.basedir}/lib/net/4.0"/>
	</if>

    <exec program="${msbuild.exe}" verbose="true">
      <arg value="Spring.NET.sln"/>
      <arg line="/nologo" />
      <arg line="/v:m" />
      <arg line="/m" />
      <arg line="/nr:false" />
      <arg line="/property:Configuration=${current.build.config}"/>
      <!--Specifying mandatory property in SDK 7-->
      <arg line='/property:Platform="Any CPU"'/>
    </exec>
	
	<call target="copylibs" />
    <call target="compile-test" />
  </target>  
  
  <target name="compile-mono-2.0" description="Builds MONO Framework 2.0 version"
          depends="set-mono-2.0-runtime-configuration, check-spring-basedir">
    <call target="copykeys" if="${project.build.sign}"/>
    <call target="common.generate-assemblyinfo"/>
    <property name="build-ems" value="false" overwrite="true" />
    <property name="build-msmq" value="false" overwrite="true" />
    <property name="build-msmq-tests" value="false" overwrite="true" />
    <call target="compile-test" />
  </target>

  <target name="copykeys">

      <if test="${not file::exists(spring.basedir + '/Spring.Net.snk')}">
          <echo message="Key file not found. You can generate a key file by running 'sn -k Spring.Net.snk'."/>
          <echo message="The generated key file should be stored in the Spring.Net base directory."/>
      </if>
      <if test="${file::exists(spring.basedir + '/Spring.Net.snk')}">
        <!-- copy the Spring key file to the location where the compiler expects it to be -->
        <copy file="Spring.Net.snk" todir="${current.bin.dir}"/>
      </if>
      <!-- for .NET 2.0 need to provide keyfile argument to compiler -->
      <if test="${net-2.0}" if="${project.build.sign}">
        <property name="compiler.args" value="/keyfile:..\..\..\Spring.Net.snk"/>
      </if>

  </target>

  <target name="copylibtobin">
    <echo message="Current bin dir = ${current.bin.dir}"/>
    <echo message="Current lib dir = ${lib.dir}"/>
    <!-- copy framework-neutral libraries -->
    <copy todir="${current.bin.dir}" verbose="${copy-verbose}">
      <fileset basedir="lib">
        <include name="*.dll"/>
        <include name="*.xml"/>
      </fileset>
    </copy>
    <!-- copy framework-specific libraries -->
    <copy todir="${current.bin.dir}" verbose="${copy-verbose}">
      <fileset basedir="${lib.dir}">
        <include name="*.dll"/>
        <include name="*.xml"/>
        <exclude name="nunit.core.*" />
      </fileset>
    </copy>
    <!-- copy nuget libs -->
    <copy todir="${current.bin.dir}" verbose="${copy-verbose}">
      <fileset basedir="${nunit.lib.dir}">
        <include name="*.dll"/>
        <include name="*.xml"/>
      </fileset>
    </copy>
  </target>

  <target name="copylibs">
	<property name="lib20.dir" value="${spring.basedir}\lib\${framework::get-family(framework::get-target-framework())}\2.0"/>
	<echo message="Current lib20 dir = ${lib20.dir}"/>
    <echo message="Current lib dir = ${lib.dir}"/>
	<mkdir dir="${lib.dir}" failonerror="false" />
	
    <copy todir="${lib.dir}" verbose="${copy-verbose}">
      <fileset basedir="${lib20.dir}">
        <include name="*.dll"/>
		<exclude if="${net-3.5}" name="**/System.Web.Extensions.dll"/>
		<exclude if="${net-4.0}" name="**/System.Web.Extensions.dll"/>
		<exclude if="${net-4.5}" name="**/System.Web.Extensions.dll"/>
        <include name="*.xml"/>
      </fileset>
    </copy>
  </target>
 
  <!-- Top level targets -->
  <!-- target for developers to do just debug build and test everything in CVS -->
  <target name="test" description="build and test">
    <echo message="Compiling debug configuration for all runtime configurations."/>
    <property name="nant.target.root.name" value="build"/>
    <call target="build-all-function"/>
  </target>
  
  <target name="build-4.5">
    <call target="set-build-namespaces-release"/>
    <echo message="------------------------"/>
    <echo message="Building .NET 4.5 DEBUG "/>
    <echo message="------------------------"/>
    <call target="set-debug-build-configuration"/>
    <call target="compile-build-4.5"/>


    <if test="${property::exists('project.build.package') and project.build.package}">
      <echo message="--------------------------"/>
      <echo message="Building .NET 4.5 RELEASE "/>
      <echo message="--------------------------"/>
      <call target="set-release-build-configuration"/>
      <call target="compile-build-4.5"/>
    </if>
  </target>  

  <target name="build-mono-2.0" if="false">

    <if test="${property::exists('project.build.package') and project.build.package}">
      <call target="set-release-build-configuration"/>
      <echo message="--------------------------"/>
      <echo message="Building MONO 2.0 RELEASE "/>
      <echo message="--------------------------"/>
      <call target="compile-build-mono-2.0"/>
    </if>

    <echo message="--------------------------"/>
    <echo message="Building MONO 2.0 DEBUG   "/>
    <echo message="--------------------------"/>
    <call target="set-debug-build-configuration"/>
    <call target="compile-build-mono-2.0"/>

  </target>

  <target name="clean" description="Deletes current build configuration">
    <call target="cleanall"/>
  </target>

  <target name="cleanall" description="Deletes every build configuration">
    <property name="target.dir" value="${path::combine(project::get-base-directory(),'build')}"/>
    <echo message="Deleting all builds from all configurations : '${target.dir}'"/>
    <delete
            dir="${project::get-base-directory()}/build/net"
            if="${directory::exists(target.dir)}"
            failonerror="false"/>
  </target>

  <target name="clean-obj" description="Clean all 'obj' and 'bin' folders">
    <delete>
      <fileset basedir="src/">
        <include name="**/bin/**/*.*" />
        <include name="**/obj/**/*.*" />
      </fileset>
    </delete>
    <delete>
      <fileset basedir="test/">
        <include name="**/bin/**/*.*" />
        <include name="**/obj/**/*.*" />
      </fileset>
    </delete>
    <delete>
      <fileset basedir="examples/">
        <include name="**/bin/**/*.*" />
        <include name="**/obj/**/*.*" />
      </fileset>
    </delete>
  </target>

  <target name="package" depends="set-package-configuration" description="Build and Package distribution">

    <property name="project.build.sign" value="true" overwrite="false" />
    <property name="project.build.package" value="true"/>

    <call target="clean-current-package-dir"/>

    <property name="nant.target.root.name" value="build"/>

    <call target="set-build-namespaces-release"/>
    <property name="project.build.sign" value="true" overwrite="false" />
    <property name="project.build.package" value="true"/>

    <call target="build-all-function"/>

    <call target="doc"/>


    <call target="package-release-files"/>
	<call target="package-nuget" />

  </target>

  <target name="doc">
    <call target="doc-reference" cascade="false" />
    <call target="doc-sdk" cascade="false" if="${doc.sdk}"/>
  </target>

  <target name="doc-reference">
    <nant buildfile="./doc/reference/docbook.build" />
  </target>

  <target name="doc-sdk">
    <echo message="Creating SDK Documentation for Spring.NET" />

    <!-- clean tmp dir -->
    <delete dir="./doc/sdk/target" failonerror="false" />

    <exec workingdir="." program="./build-support/tools/ndoc3/NDoc3Console.exe">
      <arg value="-project=./doc/sdk/Spring.NET-net-2.0.ndoc" />
    </exec>

    <!-- copy sdk docs to final destination -->
    <move todir="./doc/sdk/target/htmlhelp" overwrite="true">
      <fileset basedir="./doc/sdk/target/tmp/">
        <include name="*.chm"/>
      </fileset>
    </move>
    <move todir="./doc/sdk/target/html" overwrite="true">
      <fileset basedir="./doc/sdk/target/tmp/">
        <include name="**/*"/>
        <exclude name="*.chw" />
        <exclude name="*.hhc" />
        <exclude name="*.hhk" />
        <exclude name="*.hhp" />
        <exclude name="*.chm" />
        <exclude name="ndoc3_msdn_temp" />
      </fileset>
    </move>

    <!-- clean tmp dir -->
    <delete dir="./doc/sdk/target/tmp" failonerror="false" />

  </target>

  <target name="package-release">
    <call target="set-release-build-configuration"/>
    <call target="package-release-files"/>
  </target>

  <!--
        Target to use when packaging as a standalone .zip file. VS.NET docs
        included but compressed sdk-web directory is. Intended for mono developers
    -->
  <target name="package-zip" description="Build and Package distribution as .zip file">
    <call target="package"/>
    <property name="project.zip-path" value="${package.dir}/${project.name}-${package.version}.zip"/>
    <zip zipfile="${project.zip-path}">
      <fileset basedir="${package.dir}/${project.name}-${package.version}">
        <include name="**/*"/>
        <exclude name="**/sdk-web/**"/>
      </fileset>
    </zip>
  </target>

  <target name="dailysnapshot">
    <property name="nant.target.root.name" value="daily-build"/>
    <property name="project.build.sign" value="true"/>
    <!-- call target="copykeys"/ -->
    <!-- build all binaries -->
    <call target="build-all-function"/>
    <call target="package-cvs"/>
	
	<call target="upload-cvs-release"/>
	
  </target>

  <target name="build-all-function" description="Build what is in cvs taking into account approrpiate clr versions and root target name">

	<call target="${nant.target.root.name}-4.5" />
    <call target="build-solutions" />

  </target>
  
  <target name="daily-build-4.5">
    <call target="set-build-namespaces-all"/>
    <call target="set-package-configuration"/>
    <call target="set-debug-build-configuration"/>
    <call target="compile-build-4.5"/>
    <call target="set-release-build-configuration"/>
    <call target="compile-build-4.5"/>
  </target>

  <!-- Target to use when packaging everything in CVS -->
  <target name="package-cvs" description="Build and Package distribution">
    <property name="project.build.package" value="false"/>
    <tstamp/>
    <property name="package.version" value="${tstamp.date}-${tstamp.time}"/>

    <!-- nant buildfile="./doc/reference/docbook.build" target="all"/ -->
    <call target="doc" />

    <call target="set-debug-build-configuration"/>

    <call target="package-release-files"/>


    <property name="project.zip-path" value="${package.dir}/${project.name}-${package.version}.zip"/>
    <!-- for some reason this isn't being properly excluded in src.to.copy -->
    <delete>
      <fileset basedir="${current.package.dir}">
        <include name="**/${project.name}-SDK-HTML.zip"/>
      </fileset>
    </delete>

    <zip zipfile="${project.zip-path}">
      <fileset basedir="${current.package.dir}">
        <include name="**/*"/>
        <exclude name="**/sdk-web/**"/>
      </fileset>
    </zip>
  </target>

  <target name="package-tools">
    <!-- copy third-party tools -->
    <mkdir dir="${current.package.dir}/build-support/tools"/>
    <copy todir="${current.package.dir}/build-support/tools" verbose="${copy-verbose}">
      <fileset basedir="build-support/tools">
        <include name="antlr-2.7.6/**/*"/>
        <include name="nunit/**/*"/>
        <include name="ncover/**/*"/>
        <include name="ncoverexplorer/**/*"/>
        <include name="ndoc3/**/*"/>
      </fileset>
    </copy>
  </target>

  <target name="test-zip">
    <property name="project.build.package" value="false"/>
    <tstamp/>
    <property name="package.version" value="${tstamp.date}-${tstamp.time}"/>


    <call target="set-build-namespaces-all"/>
    <call target="set-package-configuration"/>
    <call target="set-debug-build-configuration"/>

    <property name="project.zip-path" value="${package.dir}/${project.name}-${package.version}.zip"/>

    <echo message="project.zip-path = ${project.zip-path}"/>

    <delete>
      <fileset basedir="${current.package.dir}">
        <include name="**/${project.name}-SDK-HTML.zip"/>
      </fileset>
    </delete>

    <zip zipfile="${project.zip-path}">
      <fileset basedir="${current.package.dir}">
        <include name="**/*"/>
        <exclude name="**/sdk-web/**"/>
      </fileset>
    </zip>
  </target>

  <target name="upload-cvs-release">
    <call target="set-package-configuration"/>
    <property name="filetoupload" value="${project.name}-${package.version}.zip"/>
    <property name="spring.ssh.server" value="s2-prod-wwworg-p1.vmware.com" />
    <property name="spring.web.path" value="/var/www/domains/springframework.net/www/htdocs" />
    <!-- setup property that holds partial path to be used by scp -->
    <property name="serverpart" value="${spring.ssh.server + ':' + spring.web.path}" />
    <property name="nightly.builds.path" value="downloads/nightly"/>

    <echo message="uploading ${filetoupload} to AmazonS3..."/>
    <exec workingdir="${spring.basedir}" program="cmd.exe" verbose="true">
      <arg value="/c powershell-invoker .\s3-nightly-upload.ps1 -srcFolderPath ${package.dir} -srcFilename ${filetoupload}" />
    </exec>
	
	<echo message="Deleting outdated files on AmazonS3..."/>
	<exec workingdir="${spring.basedir}" program="cmd.exe" verbose="true">
      <arg value="/c powershell-invoker .\s3-nightly-delete-old-files.ps1 -leaveLatest 10" />
    </exec>

	
  </target>

  <target name="package-release-files" depends="set-package-configuration">
    <echo message="Current package directory = ${current.package.dir}"/>
    <copy todir="${current.package.dir}" verbose="${copy-verbose}">
      <fileset>
        <include name="${solution.file.2010}"/>
        <include name="readme.txt"/>
        <include name="changelog.txt"/>
        <include name="license.txt"/>
        <include name="Spring.build"/>
        <include name="Spring.include"/>
        <include name="common-project.include"/>
        <include name="BreakingChanges.txt"/>
        <!-- exclude VS.Net stuff -->
        <exclude name="**/sdk-web/**"/>
        <exclude name="**/*.suo"/>
        <exclude name="**/*.user"/>
        <exclude name="**/bin/**"/>
        <exclude name="**/obj/**"/>
        <exclude name="**/*.resharper"/>
        <exclude name="**/*.resharper.user"/>
        <exclude name="**/Thumbs.db"/>
      </fileset>
    </copy>

    <!-- copy spring binaries -->
    <call target="package-release-files-spring.binaries" />

    <!-- copy user reference documentation -->
    <mkdir dir="${current.package.dir}/doc/reference"/>
    <copy todir="${current.package.dir}/doc/reference" verbose="${copy-verbose}">
      <fileset basedir="doc/reference/target">
        <include name="html/**/*"/>
        <include name="pdf/**/*"/>
        <include name="htmlhelp/**/*"/>
		<exclude name="**/*.ppt*" />
      </fileset>
    </copy>

    <!-- copy third-party libraries -->
    <mkdir dir="${current.package.dir}/lib/Net"/>

    <if test="${property::exists('build.allnamespaces') and not build.allnamespaces}">
      <copy todir="${current.package.dir}/lib/Net" verbose="${copy-verbose}">
        <fileset basedir="lib/Net">
          <include name="**/DotNetMock*.dll"/>
          <include name="**/log4net.dll"/>
          <include name="**/Common.Logging.dll"/>
          <include name="**/Common.Logging.Core.dll"/>
          <include name="**/antlr.runtime.dll"/>
          <include name="**/nunit.*.dll"/>
          <include name="**/nunit.*.xml"/>
          <include name="**/NUnitAsp.dll"/>
          <include name="**/NUnitAspEx.dll"/>
          <include if="${not net-4.0}" name="**/System.Web.Extensions.dll"/>
          <include name="**/Apache.NMS.dll"/>
          <include name="**/Apache.NMS.pdb"/>
          <include name="**/Apache.NMS.ActiveMQ.dll"/>
          <include name="**/Apache.NMS.ActiveMQ.pdb"/>
          <include name="**/EULA.rtf"/>
          <exclude name="**/TIBCO.EMS.ADMIN.dll"/>
          <exclude name="**/TIBCO.EMS.dll"/>
        </fileset>
      </copy>
    </if>

    <if test="${property::exists('build.allnamespaces') and build.allnamespaces}">
      <copy todir="${current.package.dir}/lib" verbose="${copy-verbose}">
        <fileset basedir="lib">
          <include name="**/*.dll"/>
          <include name="**/*.xml"/>
        </fileset>
      </copy>
    </if>

    <!-- copy additional scripts -->
    <mkdir dir="${current.package.dir}/build-support"/>
    <copy todir="${current.package.dir}/build-support" verbose="${copy-verbose}">
      <fileset basedir="build-support">
        <include name="solutions.build.nant"/>
      </fileset>
    </copy>

    <!-- copy third-party icons -->
    <mkdir dir="${current.package.dir}/build-support/icons"/>
    <copy todir="${current.package.dir}/build-support/icons" verbose="${copy-verbose}">
      <fileset basedir="build-support/icons">
        <include name="*.ico"/>
        <include name="*.pal"/>
      </fileset>
    </copy>

    <!-- copy additional convenience solution files -->
    <mkdir dir="${current.package.dir}/build-support/solutions"/>
    <copy todir="${current.package.dir}/build-support/solutions" verbose="${copy-verbose}">
      <fileset basedir="build-support/solutions">
        <include name="*.sln"/>
      </fileset>
    </copy>

    <call target="package-tools"/>

    <!-- copy schema and dtd -->
    <mkdir dir="${current.package.dir}/doc/schema"/>
    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Core/Objects/Factory/Xml/spring-objects-1.3.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Core/Objects/Factory/Xml/spring-tool-1.1.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Core/Validation/Config/spring-validation-1.3.xsd"/>


    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Aop/Aop/Config/spring-aop-1.1.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Data/Data/Config/spring-database-1.3.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Data/Transaction/Config/spring-tx-1.1.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Services/Remoting/Config/spring-remoting-1.1.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
      file="src/Spring/Spring.Services/ServiceModel/Config/spring-wcf-1.3.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Messaging.Nms/Messaging/Nms/Config/spring-nms-1.3.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Messaging.Ems/Messaging/Ems/Config/spring-ems-1.3.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="src/Spring/Spring.Template.Velocity/Template/Velocity/Config/spring-nvelocity-1.3.xsd"/>

    <copy todir="${current.package.dir}/doc/schema"
          file="build-support/install-schema.build"/>

    <mkdir dir="${current.package.dir}/bin/net/3.5/debug"/>
    <mkdir dir="${current.package.dir}/bin/net/3.5/release"/>

    <copy todir="${current.package.dir}/bin/net/3.5/debug"
          file="build-support/readme-net-3.5.txt"/>

    <copy todir="${current.package.dir}/bin/net/3.5/release"
          file="build-support/readme-net-3.5.txt"/>

    <echo message="copying source code for release..."/>

    <!-- copy source code -->
    <copy todir="${current.package.dir}" verbose="${copy-verbose}">
      <fileset refid="src.to.copy"/>
    </copy>

    <!-- copy examples -->
    <copy todir="${current.package.dir}/examples" verbose="${copy-verbose}">
        <fileset basedir="examples">
          <include name="**/*.refresh"/>
          <include name="**/*.refresh"/>
        </fileset>
    </copy>

    <!-- copy templates -->
    <copy todir="${current.package.dir}/dev-support" verbose="${copy-verbose}">
        <fileset basedir="dev-support">
          <include name="resharper/**"/>
          <include name="vs.net-2008/**"/>
		  <exclude name="**/App.AdoQuickStart/**" />
        </fileset>
    </copy>

  </target>

<!-- copy spring binaries from build dir to package bin dir -->
  <target name="package-release-files-spring.binaries">
    <!-- copy built assemblies -->
    <mkdir dir="${current.package.dir}/bin/net"/>
    <if test="${property::exists('build.allnamespaces') and not build.allnamespaces}">
      <copy todir="${current.package.dir}/bin/net" verbose="${copy-verbose}">
        <fileset basedir="./build/net">

          <include name="*/*/Common.Logging.dll"/>
          <include name="*/*/Common.Logging.Core.dll"/>

          <include name="*/*/Spring.Core.dll"/>
          <include name="*/*/Spring.Core.xml"/>
          <include name="*/*/Spring.Core.pdb"/>

          <include name="*/*/Spring.Aop.dll"/>
          <include name="*/*/Spring.Aop.xml"/>
          <include name="*/*/Spring.Aop.pdb"/>

          <include name="*/*/Spring.Data.dll"/>
          <include name="*/*/Spring.Data.xml"/>
          <include name="*/*/Spring.Data.pdb"/>

          <include name="*/*/Spring.Data.NHibernate*.dll"/>
          <include name="*/*/Spring.Data.NHibernate*.xml"/>
          <include name="*/*/Spring.Data.NHibernate*.pdb"/>
		  
          <include name="*/*/Spring.Web.dll"/>
          <include name="*/*/Spring.Web.xml"/>
          <include name="*/*/Spring.Web.pdb"/>
		  
		  <include name="*/*/Spring.Web.Mvc5.dll"/>
          <include name="*/*/Spring.Web.Mvc5.xml"/>
          <include name="*/*/Spring.Web.Mvc5.pdb"/>

          <include name="*/*/Spring.Web.Extensions.dll"/>
          <include name="*/*/Spring.Web.Extensions.xml"/>
          <include name="*/*/Spring.Web.Extensions.pdb"/>

          <include name="*/*/Spring.Services.dll"/>
          <include name="*/*/Spring.Services.xml"/>
          <include name="*/*/Spring.Services.pdb"/>

          <include name="*/*/Spring.Testing.NUnit.dll"/>
          <include name="*/*/Spring.Testing.NUnit.xml"/>
          <include name="*/*/Spring.Testing.NUnit.pdb"/>

          <include name="*/*/Spring.Testing.Microsoft.dll"/>
          <include name="*/*/Spring.Testing.Microsoft.xml"/>
          <include name="*/*/Spring.Testing.Microsoft.pdb"/>

          <include name="*/*/Spring.Messaging.Ems.dll"/>
          <include name="*/*/Spring.Messaging.Ems.xml"/>
          <include name="*/*/Spring.Messaging.Ems.pdb"/>

          <include name="*/*/Spring.Messaging.Nms.dll"/>
          <include name="*/*/Spring.Messaging.Nms.xml"/>
          <include name="*/*/Spring.Messaging.Nms.pdb"/>

          <include name="*/*/Spring.Messaging.dll"/>
          <include name="*/*/Spring.Messaging.xml"/>
          <include name="*/*/Spring.Messaging.pdb"/>

          <include name="*/*/Spring.Scheduling.Quartz3.dll"/>
          <include name="*/*/Spring.Scheduling.Quartz3.xml"/>
          <include name="*/*/Spring.Scheduling.Quartz3.pdb"/>

          <include name="*/*/Spring.Template.Velocity.dll"/>
          <include name="*/*/Spring.Template.Velocity.xml"/>
          <include name="*/*/Spring.Template.Velocity.pdb"/>

          <include name="*/*/Spring.Web.Conversation.NHibernate5.dll"/>
          <include name="*/*/Spring.Web.Conversation.NHibernate5.xml"/>
          <include name="*/*/Spring.Web.Conversation.NHibernate5.pdb"/>

        </fileset>
      </copy>
      
   </if>

    <if test="${property::exists('build.allnamespaces') and build.allnamespaces}">
      <copy todir="${current.package.dir}/bin/net" verbose="${copy-verbose}">
        <fileset basedir="./build/net">
          <include name="**/Spring.Services.*.exe"/>
          <include name="**/Spring.*.dll"/>
          <include name="**/Spring.*.xml"/>
          <include name="**/Spring.*.pdb"/>
          <include name="**/log4net.dll"/>
          <include name="**/log4net.xml"/>
          <include name="**/log4net.pdb"/>
          <include name="**/Common.Logging.dll"/>
          <include name="**/Common.Logging.xml"/>
          <include name="**/Common.Logging.Core.dll"/>
          <include name="**/Common.Logging.Core.xml"/>
          <exclude name="**/examples/**"/>
          <exclude name="**/results/**"/>
          <exclude name="**/Spring.*.Tests.dll"/>
          <exclude name="**/Spring.*.Tests.xml"/>
          <exclude name="**/Spring.*.Tests.pdb"/>
          <exclude name="**/Spring.Examples.*"/>
        </fileset>
      </copy>
    </if>
    <delete>
      <fileset basedir="${current.package.dir}/bin/net">
        <include name="**/es/**"/>
        <include name="**/PT-BR/**"/>
        <include name="**/pt-BR/**"/>
        <include name="**/sr/**"/>
        <include name="**/sr-SP-Cyrl/**"/>
        <include name="**/sr-Cyrl-CS/**"/>
        <include name="**/mpollack*/**"/>
        <include name="**/results/**"/>
        <include name="**/release/Spring/**"/>
        <include name="**/debug/Spring/**"/>
        <include name="**/debug/bin/**"/>
      </fileset>
    </delete>

  </target>

  <target name="package-sdkdocs" depends="set-package-configuration">
    <if test="${property::exists('docx.generated')}">
      <echo message="copying SDK docs..."/>
      <call target="copy-sdkdoc-spring"/>
    </if>
  </target>

  <!-- Copy over the SDK documentation generated by Document X -->
  <target name="copy-sdkdoc-spring" depends="set-package-configuration">
    <call target="set-release-build-configuration"/>
    <delete dir="${current.package.dir}/doc/sdk/1.1/htmlhelp"/>
    <delete dir="${current.package.dir}/doc/sdk/1.1/vsnet2003"/>
    <delete dir="${current.package.dir}/doc/sdk/2.0/htmlhelp"/>
    <delete dir="${current.package.dir}/doc/sdk/2.0/vsnet2005"/>

    <mkdir dir="${current.package.dir}/doc/sdk/1.1/htmlhelp"/>
    <mkdir dir="${current.package.dir}/doc/sdk/1.1/vsnet2003"/>
    <mkdir dir="${current.package.dir}/doc/sdk/2.0/htmlhelp"/>
    <mkdir dir="${current.package.dir}/doc/sdk/2.0/vsnet2005"/>

    <property name="sdk.src.dir" value="l:/release/Spring.NET" overwrite="false"/>

    <!-- Copy htmlhelp 1.0 files for 2.0 assemblies -->
    <copy todir="${current.package.dir}/doc/sdk/2.0/htmlhelp"
          file="${sdk.src.dir}/doc/sdk/Spring-1.3/net-2.0/htmlhelp1and2/Spring.NET.chm"/>

    <!-- Copy generated htmlhelp 2.x files, install scripts, -->
    <!-- and install utility for .NET 2.0 assemblies         -->
    <copy todir="${current.package.dir}/doc/sdk/2.0/vsnet2005" verbose="${copy-verbose}">
      <fileset basedir="${sdk.src.dir}/doc/sdk/Spring-1.3/net-2.0/htmlhelp1and2">
        <include name="COL_*.*"/>
      </fileset>
    </copy>
    <copy todir="${current.package.dir}/doc/sdk/2.0/vsnet2005"
          file="${sdk.src.dir}/doc/sdk/Spring-1.3/net-2.0/htmlhelp1and2/Spring.NET.hxs"/>
    <copy todir="${current.package.dir}/doc/sdk/2.0/vsnet2005"
          file="doc/InnovaHxReg.exe"/>
    <copy todir="${current.package.dir}/doc/sdk/2.0/vsnet2005"
          file="doc\docx\Spring-1.3\net-2.0\RegisterHelp2.bat"/>
    <copy todir="${current.package.dir}/doc/sdk/2.0/vsnet2005"
          file="doc\docx\Spring-1.3\net-2.0\UnRegisterHelp2.bat"/>

  </target>

  <target name="set-user-overrides" unless="${target::has-executed('set-user-overrides')}">
    <!--
             Per-user custom properties; we load any custom properties and / or
             property overrides here...

             <project name="MyCustomSpring.NETProperties">
                <property name="build-testing-microsoft" value="true"/>
             </project>

             These custom properties are loaded from a single file named
             'Spring.NET.xml' that must be placed in the ${sys.os.folder.applicationdata}
             directory. NAnt expands this property to the 'home' folder of the
             currently logged in user (on WinX boxes); for example...

             C:\Documents and Settings\Rick Evans\Application Data
        -->
    <!-- has this user specified any custom properties / property overrides? -->
    <property name="user.overrides.file" value="${sys.os.folder.applicationdata}\${project.name}.xml"/>
    <if test="${file::exists(user.overrides.file)}">
      <property name="user.overrides.present" value="true"/>
    </if>
    <if test="${not file::exists(user.overrides.file)}">
      <property name="user.overrides.present" value="false"/>
    </if>
    <!-- if so, then include all of those custom properties / property overrides -->
    <if test="${user.overrides.present}">
      <echo message="Using overrides properties file '${user.overrides.file}'."/>
      <include buildfile="${user.overrides.file}"/>
    </if>
  </target>
  <target name="set-build-namespaces-all">
    <property name="build.allnamespaces" value="true"/>
    <property name="test.integration.data" value="false" overwrite="false" />
    <property name="test.integration.ems" value="false" overwrite="false" />
    <property name="test.integration.nms" value="false" overwrite="false" />
    <property name="build-aop" value="true" />
    <property name="build-data" value="true" />
    <property name="build-conversation" value="true" />
    <property name="build-services" value="true" />
    <property name="build-testing-nunit" value="true" />
    <property name="build-testing-microsoft" value="false" />
    <property name="build-testing-microsoft" value="${property::exists('mstest.exe')}" />
    <property name="run-testing-microsoft" value="${not property::exists('skipmstestrun')}" />
    <property name="build-web" value="true" />
    <property name="build-nms" value="true" />
    <property name="build-ems" value="${file::exists('lib/net/2.0/tibco.ems.dll')}" />
    <property name="build-quartz" value="true" />
    <property name="build-msmq" value="true" />
    <property name="build-velocity" value="true" />
    <property name="solution.file" value="Spring.Net.sln"/>
    <fileset id="src.to.copy">
      <include name="src/**"/>
      <include name="examples/**"/>
      <include name="test/**"/>
      <!-- exclude VS.Net stuff -->
      <exclude name="**/*.suo"/>
      <exclude name="**/*.user"/>
      <exclude name="**/bin/**"/>
      <exclude name="**/obj/**"/>
      <exclude name="**/_ReSharper*/**"/>
      <exclude name="**/build/**"/>
      <exclude name="**/sdk-web/**"/>
      <exclude name="**/POC/**"/>
      <exclude name="**/sdk/net/1.1/${project.name}-SDK-HTML.zip"/>
      <exclude name="examples/Spring/SpringAir/src/SpringAir.Web.2005.References/*.dll"/>
      <exclude name="examples/Spring/SpringAir/src/SpringAir.Web.2005.References/*.pdb"/>
      <exclude name="examples/Spring/SpringAir/src/SpringAir.Web.2005.References/*.xml"/>
      <exclude name="examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/*.dll"/>
      <exclude name="examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/*.pdb"/>
      <exclude name="examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web.References/*.xml"/>
    </fileset>
  </target>
  <target name="set-build-namespaces-release">
    <property name="test.integration.data" value="false" overwrite="false" />
    <property name="test.integration.ems" value="false" overwrite="false" />
    <property name="test.integration.nms" value="false" overwrite="false" />
    <property name="build-aop" value="true"/>
    <property name="build-data" value="true"/>
    <property name="build-conversation" value="true" />
    <property name="build-services" value="true"/>
    <property name="build-testing-nunit" value="true"/>
    <property name="build-testing-microsoft" value="false" />
    <property name="build-testing-microsoft" value="${property::exists('mstest.exe')}" />
    <property name="run-testing-microsoft" value="${not property::exists('skipmstestrun')}" />
    <property name="build-web" value="true"/>
    <property name="build-examples" value="true"/>
    <property name="build-nms" value="true" />
    <property name="build-ems" value="${file::exists('lib/net/2.0/tibco.ems.dll')}" />
    <property name="build-quartz" value="true" />
    <property name="build-msmq" value="true" />
    <property name="build-velocity" value="true" />
    <property name="solution.file.2010" value="Spring.Net.sln"/>
    <fileset id="src.to.copy">
      <include name="src/Spring/Spring.Core/**"/>
      <include name="src/Spring/Spring.Aop/**"/>
      <include name="src/Spring/Spring.Web/**"/>
      <include name="src/Spring/Spring.Web.Mvc5/**"/>
      <include name="src/Spring/Spring.Web.Extensions/**"/>
      <include name="src/Spring/Spring.Services/**"/>
      <include name="src/Spring/Spring.Data/**"/>
      <include name="src/Spring/Spring.Data.NHibernate5/**"/>
      <include name="src/Spring/Spring.Messaging/**"/>
      <include name="src/Spring/Spring.Messaging.Nms/**"/>
      <include name="src/Spring/Spring.Messaging.Ems/**"/>
      <include name="src/Spring/Spring.Scheduling.Quartz3/**"/>
      <include name="src/Spring/Spring.Template.Velocity/**"/>
      <include name="src/Spring/Spring.Testing.NUnit/**"/>
      <include name="src/Spring/Spring.Testing.Microsoft/**"/>
      <include name="src/Spring/CommonAssemblyInfo.cs"/>
      <include name="src/Spring/Spring.Web.Conversation.NHibernate5/**"/>
      
      <include name="test/Spring/Spring.Core.Tests/**"/>
      <include name="test/Spring/Spring.Aop.Tests/**"/>
      <include name="test/Spring/Spring.Web.Tests/**"/>
	  <include name="test/Spring/Spring.Web.Mvc5.Tests/**"/>
      <include name="test/Spring/Spring.Services.Tests/**"/>
      <include name="test/Spring/Spring.Data.Tests/**"/>
      <include name="test/Spring/Spring.Data.Integration.Tests/**"/>
      <include name="test/Spring/Spring.Data.NHibernate5.Integration.Tests/**"/>	  
	  <include name="test/Spring/Spring.Data.NHibernate5.NestedTxSuspension.Integration.Tests/**"/>	  
	  <include name="test/Spring/Spring.Data.NHibernate5.Tests/**"/>
      <include name="test/Spring/Spring.Messaging.Tests/**"/>
      <include name="test/Spring/Spring.Messaging.Nms.Tests/**"/>
      <include name="test/Spring/Spring.Messaging.Nms.Integration.Tests/**"/>
      <include name="test/Spring/Spring.Messaging.Ems.Tests/**"/>
      <include name="test/Spring/Spring.Scheduling.Quartz3.Tests/**"/>
      <include name="test/Spring/Spring.Template.Velocity.Tests/**"/>
      <include name="test/Spring/Spring.Testing.NUnit.Tests/**"/>
      <include name="test/Spring/Spring.Testing.Microsoft.Tests/**"/>
      <include name="test/Spring/CommonAssemblyInfo.cs"/>
      <include name="test/Spring/Spring.Web.Conversation.NHibernate5.Tests/**"/>
      
      <include name="examples/Spring/Spring.Examples.build"/>
      <include name="examples/Spring/Spring.AopQuickStart/**"/>
      <include name="examples/Spring/Spring.DataQuickStart/**"/>
      <include name="examples/Spring/Spring.Data.NHibernate.Northwind/**"/>
      <include name="examples/Spring/Spring.Data.NHibernate.Northwind/src/Spring.Northwind.Web/Bin/*.refresh"/>
      <include name="examples/Spring/Spring.TxQuickStart/**"/>
      <include name="examples/Spring/Spring.IoCQuickStart.AppContext/**"/>
      <include name="examples/Spring/Spring.IoCQuickStart.EventRegistry/**"/>
      <include name="examples/Spring/Spring.IoCQuickStart.MovieFinder/**"/>
      <include name="examples/Spring/Spring.CachingQuickStart/**"/>
      <include name="examples/Spring/Spring.Calculator/**"/>
      <include name="examples/Spring/Spring.Calculator/src/Spring.Calculator.Web.2005/Bin/*.refresh"/>
      <include name="examples/Spring/Spring.WebQuickStart/**"/>
	  <include name="examples/Spring/Spring.Mvc5QuickStart/**"/>
	  <include name="examples/Spring/Spring.Web.Extensions.Example/**"/>
      <include name="examples/Spring/Spring.Web.Extensions.Example/src/Spring.Web.Extensions.Example.2005/Bin/*.refresh"/>
      <include name="examples/Spring/SpringAir/**"/>
      <include name="examples/SpringAir/src/SpringAir.Web.2005/bin/*.refresh"/>
      <include name="examples/Spring/Spring.Scheduling.Quartz.Example/**"/>
      <include name="examples/Spring/Spring.NmsQuickStart/**"/>
      <include name="examples/Spring/Spring.EmsQuickStart/**"/>
      <include name="examples/Spring/Spring.MsmqQuickStart/**"/>
      <include name="examples/Spring/Spring.WcfQuickStart/**"/>
      <include name="examples/Spring/Spring.Scheduling.Quartz.Example/**"/>


      <exclude name="examples/Spring/Spring.Data.NHibernate.Northwind/Debug*.sln"/>
      <exclude name="examples/Spring/Spring.Data.NHibernate.Northwind/Spring.Northwind.sln"/>

      <!-- exclude VS.Net stuff -->
      <exclude name="**/sdk-web/**"/>
      <exclude name="**/*.sln.cache"/>
      <exclude name="**/*.suo"/>
      <exclude name="**/*.user"/>
      <exclude name="**/bin/**"/>
      <exclude name="**/obj/**"/>
      <exclude name="**/_ReSharper*/**"/>
      <exclude name="**/.idea/**"/>
      <exclude name="**/build/**"/>
      <exclude name="**/*.resharper"/>
    </fileset>
  </target>

  <!-- build all Visual Studio Solutions -->
  <target name="build-solutions" description="Build the solutions">
    <!-- some examples are linked against the "bin" dir of the distribution so copy them from 'build' to 'bin' -->
    <delete dir="${spring.basedir}/bin" />

    <property name="current.package.dir" value="${spring.basedir}" />
    <call target="package-release-files-spring.binaries" />

    <!-- rebuild all solutions -->
    <nant buildfile="build-support/solutions.build.nant">
      <properties>
        <property name="root.dir" value="${spring.basedir}" />
      </properties>
    </nant>
    <!-- be nice and cleanup after building -->
    <nant buildfile="build-support/solutions.build.nant" target="Clean">
      <properties>
        <property name="root.dir" value="${spring.basedir}" />
      </properties>
    </nant>
  </target>
  
  
  <target name="check-nuget-package-dir">
    <fail message="The NuGet package directory has not been specified."
          if="${not property::exists('nuget.package.dir')}"/>
    <!-- <mkdir dir="${nuget.package.dir}"/> -->
  </target>
  
  
<target name="clean-nuget-package-dir" depends="check-nuget-package-dir" description="Cleans the NuGet package directory">
    <echo message="Cleaning the ${nuget.package.dir} NuGet package directory."/>
    
	<delete failonerror="false" if="${directory::exists(nuget.package.dir)}">
	  <fileset basedir="${nuget.package.dir}">
		<include name="*.nupkg"/> 
	  </fileset>           
    </delete>   
		
	<mkdir dir="${nuget.package.dir}" if="${directory::exists(nuget.package.dir)}"/>
  </target>

<target name="set-nuget-package-version" >

	<!-- assume version of nuget package matches version of assemblies contained within it -->
	<property name="nuget.package.version" value="${package.version}" />
	
	<!-- if suffix is passed in, use it -->
	<property name="nuget.package.version" value="${package.version + '-' + nuget.version.suffix}" if="${property::exists('nuget.version.suffix')}" />

</target>
  
<target name="package-nuget" depends="set-nuget-package-version,update-nuspec-metadata">

	<property name="nuget.package.dir" value="${spring.basedir}\nuget-packages" />
	
	<call target="clean-nuget-package-dir" />
	<call target="check-package-version" />
	
	<foreach item="File" property="filename">
		<in>
			<items basedir="${spring.basedir}/src/Spring">
				<include name="**/*.csproj" />
				<exclude name="**/Spring.Messaging.Ems.csproj*" unless="${build-ems}" />
			</items>
		</in>
		<do>
			<echo message="Generating NuGet Package from nuspec file: ${filename}" />  
			<exec program="dotnet" verbose="true">
			  <arg value="pack" />
			  <arg value="-c" />
			  <arg value="Release" />
			  <arg value="-p:PackageVersion=${nuget.package.version}" />
			  <arg value="-o" />
			  <arg value="${nuget.package.dir}" />
			  <arg value="${filename}" />
			</exec>
		</do>
	</foreach>
</target>

<target name="update-nuspec-metadata" depends="set-nuget-package-version">  
</target>


</project>
