<?xml version="1.0" ?>
<!--
Copyright 2004-2006 The Apache Software Foundation

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<project name="log4net-samples" default="compile-all" xmlnds="http://tempuri.org/nant-vs.xsd">
    <property name="log4net.basedir" value="../" readonly="false" />
    <property name="project.build.config" value="debug" readonly="false" />
    <property name="project.build.package" value="false" readonly="false" />
    <!-- Include log4net helpers -->
    <include buildfile="${log4net.basedir}/log4net.include" />
    <!-- Targets that should always be executed -->
    <call target="set-build-configuration" />
    <call target="set-framework-configuration" />

    <!-- Target for compiling the tests on all frameworks -->
    <target name="compile-all" description="Builds all log4net tests">
        <echo message="Compiling all runtime configurations for the ${current.build.config} build configuration." />

        <if test="${framework::exists('net-1.0')}">
            <call target="compile-net-1.0" />
        </if>
        <if test="${not framework::exists('net-1.0')}">
            <if test="${property::exists('project.build.package') and project.build.package}">
                <fail message="The .NET Framework 1.0 is not available." />
            </if>
            <if test="${not(property::exists('project.build.package') and project.build.package)}">
                <echo message="The .NET Framework 1.0 is not available. Build skipped." />
            </if>
        </if>

        <if test="${framework::exists('net-2.0')}">
            <call target="compile-net-2.0" />
        </if>
        <if test="${not framework::exists('net-2.0')}">
            <if test="${property::exists('project.build.package') and project.build.package}">
                <fail message="The .NET Framework 2.0 is not available." />
            </if>
            <if test="${not(property::exists('project.build.package') and project.build.package)}">
                <echo message="The .NET Framework 2.0 is not available. Build skipped." />
            </if>
        </if>

        <if test="${framework::exists('net-1.1')}">
            <call target="compile-net-1.1" />
        </if>
        <if test="${not framework::exists('net-1.1')}">
            <if test="${property::exists('project.build.package') and project.build.package}">
                <fail message="The .NET Framework 1.1 is not available." />
            </if>
            <if test="${not(property::exists('project.build.package') and project.build.package)}">
                <echo message="The .NET Framework 1.1 is not available. Build skipped." />
            </if>
        </if>
    </target>

    <!-- Target for compiling the tests on net-1.0 -->
    <target name="compile-net-1.0" description="Builds log4net tests .NET Framework 1.0 version" depends="set-net-1.0-runtime-configuration, check-log4net-basedir, clean-current-bin-dir">
        <!-- copy log4net build output -->
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/${current.bin.dir}">
                <include name="*.*" />
            </fileset>
        </copy>
        <!-- copy referenced libraries to build output -->
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/tests/lib">
                <include name="/*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <csc nostdlib="true" noconfig="true" warnaserror="true" target="library" debug="${current.build.debug}" define="${current.build.defines.csc}" output="${current.bin.dir}/log4net.Tests.dll">
            <sources basedir="${log4net.basedir}/tests/src">
                <include name="**/*.cs" />
                <include name="../../src/AssemblyVersionInfo.cs" />
            </sources>
            <references defaultexcludes="true">
                <include name="mscorlib.dll" />
                <include name="System.dll" />
                <include name="System.Data.dll" />
                <include name="System.Web.dll" />
                <include name="System.Xml.dll" />
                <include name="System.Runtime.Remoting.dll" />
                <include name="${current.bin.dir}/log4net.dll" frompath="false" />
                <!-- allow for third party assemblies to be referenced by just storing them in the lib/<framework>/<framework version>/<build configuration> directory -->
                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
            </references>
        </csc>
    </target>

    <!-- Target for compiling the tests on net-1.1 -->
    <target name="compile-net-1.1" description="Builds log4net tests .NET Framework 1.1 version" depends="set-net-1.1-runtime-configuration, check-log4net-basedir, clean-current-bin-dir, check-log4net-assembly">
        <!-- copy log4net build output -->
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/${current.bin.dir}">
                <include name="*.*" />
            </fileset>
        </copy>
        <!-- copy referenced libraries to build output -->
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/tests/lib">
                <include name="/*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <csc nostdlib="true" noconfig="true" warnaserror="true" target="library" debug="${current.build.debug}" define="${current.build.defines.csc}" output="${current.bin.dir}/log4net.Tests.dll">
            <sources basedir="${log4net.basedir}/tests/src">
                <include name="**/*.cs" />
                <include name="../../src/AssemblyVersionInfo.cs" />
            </sources>
            <references defaultexcludes="true">
                <include name="mscorlib.dll" />
                <include name="System.dll" />
                <include name="System.Data.dll" />
                <include name="System.Web.dll" />
                <include name="System.Xml.dll" />
                <include name="System.Runtime.Remoting.dll" />
                <include name="${current.bin.dir}/log4net.dll" frompath="false" />
                <!-- allow for third party assemblies to be referenced by just storing them in the lib/<framework>/<framework version>/<build configuration> directory -->
                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
            </references>
        </csc>
    </target>

    <target name="compile-net-2.0" description="Builds log4net tests .NET Framework 2.0 version" depends="set-net-2.0-runtime-configuration, check-log4net-basedir, clean-current-bin-dir, check-log4net-assembly">
        <!-- copy log4net build output -->
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/${current.bin.dir}">
                <include name="*.*" />
            </fileset>
        </copy>
        <!-- copy referenced libraries to build output -->
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/tests/lib">
                <include name="/*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <copy todir="${current.bin.dir}">
            <fileset basedir="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}">
                <include name="*.dll" />
            </fileset>
        </copy>
        <csc nostdlib="true" noconfig="true" warnaserror="true" target="library" debug="${current.build.debug}" define="${current.build.defines.csc}" output="${current.bin.dir}/log4net.Tests.dll">
            <sources basedir="${log4net.basedir}/tests/src">
                <include name="**/*.cs" />
                <include name="../../src/AssemblyVersionInfo.cs" />
            </sources>
            <references defaultexcludes="true">
                <include name="mscorlib.dll" />
                <include name="System.dll" />
                <include name="System.Data.dll" />
                <include name="System.Web.dll" />
                <include name="System.Xml.dll" />
                <include name="System.Runtime.Remoting.dll" />
                <include name="${current.bin.dir}/log4net.dll" frompath="false" />
                <!-- allow for third party assemblies to be referenced by just storing them in the lib/<framework>/<framework version>/<build configuration> directory -->
                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
                <include name="lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/${current.build.config}/*.dll" frompath="false" />
                <include name="${log4net.basedir}/lib/${framework::get-family(framework::get-target-framework())}/${framework::get-version(framework::get-target-framework())}/*.dll" frompath="false" />
            </references>
        </csc>
    </target>

    <!-- Currently we cannot run the tests in the environment of the target framework only in the host framework -->

    <target name="runtests" description="Runs log4net tests">
        <call target="runtests-net-1.0" />
    </target>
    
    <target name="runtests-net-1.0" description="Runs log4net tests on .NET Framework 1.0 version" depends="compile-net-1.0">
        <nunit2>
            <formatter type="Plain" />
            <test assemblyname="${current.bin.dir}/log4net.Tests.dll" />
        </nunit2>
    </target>

</project>
