<?xml version="1.0" ?>
<project name="umbraco" default="test" basedir=".">
	<description>Build the umbraco 4.6 Application for asp.net 3.5</description>

   <property name="nant.settings.currentframework" value="net-2.0" />
   
	<!-- filenames and directories, generally won't change -->

	<property name="public.dir" value="C:\Users\per\Documents\Projects\NugetServer\GalleryServer\src\Gallery.Server\App_Data\packages" />
	

	<property name="root.dir" value="${directory::get-current-directory()}" />
	<property name="source.dir" value="${root.dir}\umbraco\presentation" />
	<property name="build.dir" value="${root.dir}\build" />
	<property name="dlls.dir" value="${root.dir}\foreign dlls" />

	<property name="nuget.dir" value="${root.dir}\nuget" />
	<property name="nuget.app" value="C:\Program Files (x86)\nuget\nuget.exe" />
	<property name="nuget.spec" value="${public.dir}\..\umbraco.nuspec" />

	<property name="build.version" value="4.6.Beta"/>

	<property name="win.dir" value="C:\windows" />

	<target name="build" depends="init">
		<!-- set everything to writable-->
		<attrib normal="true" readonly="false">
			<fileset basedir="${root.dir}">
				<include name="**/*" />
			</fileset>
		</attrib>

		<!-- Remove those damn DLR dlls that might be left behind by careless devs...-->
		<!-- They will get added again after build is completed, no worries no dependencies during build-->
		<delete>
			<fileset>
				<include name="${source.dir}\bin\IronPython.dll" />
				<include name="${source.dir}\bin\IronPython.Modules.dll" />
				<include name="${source.dir}\bin\IronRuby.dll" />
				<include name="${source.dir}\bin\IronRuby.Libraries.dll" />
				<include name="${source.dir}\bin\IronRuby.Libraries.Yaml.dll" />
				<include name="${source.dir}\bin\Microsoft.Dynamic.dll" />
				<include name="${source.dir}\bin\Microsoft.ScriptinG.Core.dll" />
				<include name="${source.dir}\bin\Microsoft.Scripting.Debugging.dll" />
				<include name="${source.dir}\bin\Microsoft.Scripting.dll" />
				<include name="${source.dir}\bin\Microsoft.Scripting.ExtensionAttribute.dll" />
			</fileset>
		</delete>
		
		<!-- build for 2.0 -->
		<exec program="${win.dir}\microsoft.net\framework\v4.0.30319\msbuild.exe">
			<arg value="${root.dir}\umbraco.sln" />
			<arg value="/v:n" />
			<arg value="/p:WarningLevel=0" />
			<arg value="/p:ToolsVersion=3.5" />
		</exec>
		<exec program="${win.dir}\microsoft.net\framework\v2.0.50727\aspnet_compiler.exe" commandline="-f -u -p umbraco/presentation -v / &quot;${build.dir}\Net20&quot;"/>
		

		<!-- build for 4.0 -->
		<exec program="${win.dir}\microsoft.net\framework\v4.0.30319\msbuild.exe">
			<arg value="${root.dir}\umbraco.sln" />
			<arg value="/v:n" />
			<arg value="/p:WarningLevel=0" />
			<arg value="/p:ToolsVersion=4.0" />
		</exec>
		<exec program="${win.dir}\microsoft.net\framework\v2.0.50727\aspnet_compiler.exe" commandline="-f -u -p umbraco/presentation -v / &quot;${build.dir}\Net40&quot;"/>
	</target>
	


	<!-- Directories and files -->
	<target name="directories" depends="build">
		<!-- asp.net 2.0 SP1 DLR dlls -->
		<delete>
			<fileset>
				<include name="${build.dir}\**\*" />

				<exclude name="${build.dir}\**\businesslogic.dll" />
				<exclude name="${build.dir}\**\cms.dll" />
				<exclude name="${build.dir}\**\controls.dll" />
				<exclude name="${build.dir}\**\Examine.dll" />

				<exclude name="${build.dir}\**\interfaces.dll" />
				<exclude name="${build.dir}\**\Microsoft.ApplicationBlocks.Data.dll" />
				<exclude name="${build.dir}\**\umbraco.DataLayer.dll" />
				<exclude name="${build.dir}\**\umbraco.dll" />
				<exclude name="${build.dir}\**\umbraco.editorcontrols.dll" />
				<exclude name="${build.dir}\**\umbraco.linq.core.dll" />
				<exclude name="${build.dir}\**\umbraco.macrorenderings.dll" />
				<exclude name="${build.dir}\**\umbraco.providers.dll" />
				<exclude name="${build.dir}\**\UmbracoExamine.dll" />
			</fileset>
		</delete>
		
		<copy todir="${nuget.dir}\lib\Net20">
			<fileset basedir="${build.dir}\Net20\bin">
				<include name="*.dll" />
			</fileset>
		</copy>

		<copy todir="${nuget.dir}\lib\Net40">
			<fileset basedir="${build.dir}\Net40\bin">
				<include name="*.dll" />
			</fileset>
		</copy>

		<copy file="${nuget.spec}" tofile="${nuget.dir}\umbraco.nuspec" failonerror="false" overwrite="true"/>

		<xmlpoke
				file="${nuget.dir}\umbraco.nuspec"
				xpath="/package/metadata/version"
				value="${build.version}" />
						
	</target>

	
	<!-- will produce the a clean /build folder and nothing else-->
	<target name="nuget" depends="directories">
		 <exec program="${nuget.app}" commandline="pack &quot;${nuget.dir}\umbraco.nuspec&quot; /o &quot;${public.dir}&quot;"/>
	</target>

   
   <target name="test">
		 <exec program="${nuget.app}" commandline="pack &quot;${nuget.dir}\umbraco.nuspec&quot; /o &quot;${public.dir}&quot;"/>
	</target>

	<target name="init" description="init tasks for the build">

		<!-- Clean the plugins dir any leftovers, only tinyMCE belongs in here -->
		<delete>
			<fileset>
				<include name="${build.dir}\umbraco\plugins\*" />
				<exclude name="${build.dir}\umbraco\plugins\tinymce3" />
			</fileset>
		</delete>

		<delete dir="${build.dir}" />
		<mkdir dir="${build.dir}" />

		 <delete dir="${nuget.dir}" />
		<mkdir dir="${nuget.dir}" />
		<mkdir dir="${nuget.dir}\lib\Net20" />
		<mkdir dir="${nuget.dir}\lib\Net40" />

	</target>


</project>
