<project>
	<!-- do checks for required parameters -->
	<if test="${not property::exists('CCnetDir')}">
		<!-- property is neccessary to be able to use the msbuild xml logger -->
		<fail message="CCnetDir property not specified!"/>
	</if>
	<if test="${not property::exists('NUnitDir')}">
		<!-- property is neccessary to be able to run nunit tests -->
		<fail message="NUnitDir property not specified!"/>
	</if>
	<!-- end of check for required parameters -->
	<property name="IsCIRun" value="false" unless="${property::exists('IsCIRun')}"/>
	
	<property name="BaseRepositoryPath" value="${directory::get-parent-directory(directory::get-parent-directory(directory::get-parent-directory(directory::get-parent-directory(project::get-base-directory()))))}"/>
	<property name="CosmosSlnBuildOutputDir" value="${path::combine(BaseRepositoryPath, 'BuildOutput')}"/>
	<delete dir="${CosmosSlnBuildOutputDir}" unless="${not directory::exists(CosmosSlnBuildOutputDir)}"/>
	<mkdir dir="${CosmosSlnBuildOutputDir}"/>

	<property name="BuildResultsDir" value="${path::combine(BaseRepositoryPath, 'BuildOutput')}"/>
	<delete dir="${BuildResultsDir}" unless="${not directory::exists(BuildResultsDir)}"/>
	<mkdir dir="${BuildResultsDir}"/>

	
	<echo message="${BaseRepositoryPath}"/>
	
	<!-- first compile Cosmos.sln -->
	<msbuild project="${path::combine(path::combine(BaseRepositoryPath, 'Source'), 'Cosmos.sln')}"
					 target="Rebuild"
					 verbosity="Minimal">
		<arg line="/p:OutputPath=&quot;${CosmosSlnBuildOutputDir}&quot;"/>
		<arg line="/p:Configuration=Debug"/>
		<!--<arg line="/logger:&quot;${path::combine(CCnetDir, 'ThoughtWorks.CruiseControl.MSBuild.dll')}&quot;"/>-->
	</msbuild>

	<exec program="${path::combine(NUnitDir, 'nunit-console.exe')}" failonerror="false" workingdir="${CosmosSlnBuildOutputDir}">
		<arg line="Indy.IL2CPU.Tests.dll /exclude=NOTWORKING /xml=&quot;${path::combine(BuildResultsDir, 'UnitTests-Results.xml')}&quot;"/>
	</exec>
	
	<exec program="${path::combine(BuildResultsDir, 'Cosmos.TestRunner.exe')}" failonerror="false" workingdir="${BuildResultsDir}">
	</exec>
</project>