<Project DefaultTargets="Ayuda" InitialTargets="GetPaths;GetProjects;CreateOutputPath" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
     <!-- ASCII Constants -->
	<PropertyGroup>
        <NEW_LINE>%0D%0A</NEW_LINE>
		<HARD_NEW_LINE>%0A%0D%0C%08</HARD_NEW_LINE>
		<SOFT_NEW_LINE>%0A%20%08</SOFT_NEW_LINE>
        <TAB>%09</TAB>
		<AT_SIGN>%40</AT_SIGN>
		<PERCENT_SIGN>%25</PERCENT_SIGN>
		<DOUBLE_QUOTES>%22</DOUBLE_QUOTES>
		<SINGLE_QUOTE>%27</SINGLE_QUOTE>
		<CR>%0D</CR>
		<LF>%0A</LF>
        <SPACE>%20</SPACE>
     </PropertyGroup>
     
     <!-- Solution Folders -->
     <PropertyGroup>
		<FBScriptFolder>$(MSBuildProjectDirectory)\Build</FBScriptFolder>
        <CodeFolder>$(MSBuildProjectDirectory)\Source</CodeFolder>
        <InstallerFolder>$(MSBuildProjectDirectory)\Installer</InstallerFolder>
        <SqlFolder>$(MSBuildProjectDirectory)\Database</SqlFolder>
        <LibFolder>$(MSBuildProjectDirectory)\Lib</LibFolder>
        <InstallFolder>$(MSBuildProjectDirectory)\Install</InstallFolder>
        <CodeOutputFolder>$(MSBuildProjectDirectory)\Output</CodeOutputFolder>
        <SqlScriptsFolder>$(SqlFolder)\Scripts</SqlScriptsFolder>
        <CodeMetricsFolder>$(MSBuildProjectDirectory)\Code Metrics</CodeMetricsFolder>
		<ToolsFolder>$(MSBuildProjectDirectory)\Tools</ToolsFolder>
        <QtpFolder>$(MSBuildProjectDirectory)\Qtp</QtpFolder>
        <QtpDeployFolder Condition=" '$(QtpDeployFolder)' == '' ">\\qtpserver\qtpshare</QtpDeployFolder> 
        <QtpInstallFolder>$(QtpDeployFolder)\Install</QtpInstallFolder> 
        <QtpUninstallFolder>$(QtpDeployFolder)\Uninstall</QtpUninstallFolder>       
        <QtpResultsFolder Condition=" '$(QtpResultsFolder)' == '' ">$(QtpFolder)\TestResults</QtpResultsFolder>
     </PropertyGroup>
	 
     <!-- Environment Settings -->
     <PropertyGroup>
        <Environment>DEV</Environment>		
		<DBServer Condition=" '$(DBServer)' == '' ">localhost</DBServer>
        <DBMS>firebird2</DBMS>
		<DBUser Condition=" '$(DBUser)' == '' ">sysdba</DBUser>
		<DBPassword Condition=" '$(DBPassword)' == '' ">masterkey</DBPassword>
        <SqlCmdRunner>$(ToolsFolder)\ISQL\isql.exe</SqlCmdRunner>
        <SmtpServer>smtp.somewhere.co.za</SmtpServer>
     </PropertyGroup>
  
     <!-- 3rd Party Program Settings -->
     <PropertyGroup>
		<FinalBuilderPath>C:\Archivos de programa\FinalBuilder 5</FinalBuilderPath>
		<FinalBuilderCmd>$(FinalBuilderPath)\FBCMD.exe</FinalBuilderCmd>
        <SubversionPath>C:\Program Files\Subversion\bin</SubversionPath>
        <SubversionCmd>$(SubversionPath)\svn.exe</SubversionCmd>
        <NCoverPath>C:\Program Files\NCover\</NCoverPath>
        <NCoverExplorerPath>C:\Program Files\NCoverExplorer\</NCoverExplorerPath>
        <NUnitPath>C:\Program Files\NUnit-Net-2.0 2.2.10\bin</NUnitPath>
        <NUnitCmd>$(NUnitPath)\nunit-console.exe</NUnitCmd>
        <InstallShieldPath>C:\Program Files\Installshield 12 StandaloneBuild</InstallShieldPath>
        <InstallShieldCmd>$(InstallShieldPath)\IsSaBld.exe</InstallShieldCmd>
     </PropertyGroup>
  
 
     <!-- Solution Files -->
     <PropertyGroup>
        <KeyFile>..\Sanlam.snk</KeyFile>
        <SolutionName>Sanlam.SanQuote.sln</SolutionName>
        <IterationNumberFile>$(MSBuildProjectDirectory)\IterationNumber.txt</IterationNumberFile>
        <EnvironmentFile>$(MSBuildProjectDirectory)\Environment.txt</EnvironmentFile>
        <LastTestRunSucceededFile>LastTestRunSucceeded</LastTestRunSucceededFile>
        <LastCodeAnalysisSucceededFile>LastCodeAnalysisSucceeded</LastCodeAnalysisSucceededFile>
        <InstallBuildEmailFile>$(Temp)\InstallBuildEmailFile.htm</InstallBuildEmailFile>
        <InstallBuildEmailTemplate>$(InstallFolder)\InstallBuildEmailTemplate.htm</InstallBuildEmailTemplate>
        <NUnitFile>TestResult.xml</NUnitFile>
        <FxCopFile>CodeAnalysisLog.xml</FxCopFile>
        <NCoverFile>Coverage.xml</NCoverFile>
        <NCoverLogFile>Coverage.log</NCoverLogFile>
        <NCoverSummaryFile>CoverageSummary.xml</NCoverSummaryFile>
        <NCoverHtmlReport>CoverageSummary.html</NCoverHtmlReport>
        <DBBackupScript>$(SqlScriptsFolder)\CreateDBBackupsForAutomatedBuild.cmd</DBBackupScript>
        <QtpRunTestsScriptFile>$(QtpFolder)\RunQTP.vbs</QtpRunTestsScriptFile>
        <QtpResultsSummaryFile>QtpResultsSummary.xml</QtpResultsSummaryFile>
     </PropertyGroup>
  
     <!-- Subversion Settings -->
     <PropertyGroup>
        <SvnLocalPath>$(MSBuildProjectDirectory)</SvnLocalPath>
        <SvnServerPath>https://svn.somewhere.co.za/sanquote</SvnServerPath>      
        <SvnTrunkFolder>$(SvnServerPath)/trunk</SvnTrunkFolder>
        <SvnTagsFolder>$(SvnServerPath)/tags</SvnTagsFolder>
     </PropertyGroup>
  
     <!-- InstallShield Settings -->
     <PropertyGroup>
        <MsiInstallFile>SanQuote.msi</MsiInstallFile>
        <InstallShieldProjectFile>$(InstallFolder)\SanQuote.ism</InstallShieldProjectFile>
        <SetMsiProductVersionScript>$(InstallFolder)\SetMsiProductVersion.vbs</SetMsiProductVersionScript>
        <InstallShieldInputFolder>$(InstallFolder)\Binaries\InstallFiles</InstallShieldInputFolder>
        <InstallShieldOutputFolder>$(Temp)\SanQuote\Install</InstallShieldOutputFolder>
        <InstallShieldBuildFolders>PROJECT_ASSISTANT\SINGLE_MSI_IMAGE\DiskImages\DISK1</InstallShieldBuildFolders>
        <InstallShieldMergeModulesFolder>$(InstallFolder)\Merge Modules</InstallShieldMergeModulesFolder>
     </PropertyGroup>
  
     <!-- Misc Settings -->
     <PropertyGroup>
        <Major>1</Major>
        <Minor>0</Minor>
        <Build>$(Iteration)</Build>
        <BuildTargets Condition=" '$(BuildTargets)' == '' ">Build</BuildTargets>
        <DeploymentBuild Condition=" '$(DeploymentBuild)' == '' ">false</DeploymentBuild>
     </PropertyGroup>
  
     <!-- Overriding .csproj Project settings -->
     <PropertyGroup>
        <OutputPath Condition=" '$(OutputPath)' == '' ">$(CodeOutputFolder)</OutputPath>
        <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
        <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
        <RunCodeAnalysis Condition=" '$(RunCodeAnalysis)' == '' ">false</RunCodeAnalysis>	
		<OutputPath Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">$(CodeOutputFolder)\Debug</OutputPath>
		<OutputPath Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">$(CodeOutputFolder)\Release</OutputPath>
     </PropertyGroup>
  
     <!-- Only import the other targets here after the property definitions above have been defined -->
     <Import Project="$(MSBuildProjectDirectory)\RodaxSoftware.FactuGES.Common.targets"/>
	 <Import Project="C:\Archivos de programa\MSBuild\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets"/>
     <!-- <Import Project="C:\Program Files\TypeMock\TypeMock.NET\TypeMock.MSBuild.Tasks"/>-->
     <!--<Import Project="$(MSBuildExtensionsPath)\NCoverExplorerTasks\NCoverExplorer.MSBuildTasks.targets"/>-->
  
     <!-- Add our CleanSolution task to the general Clean task -->
     <PropertyGroup>
        <CleanDependsOn>
           $(CleanDependsOn);
		    	 CleanDatabase
           CleanCode
           CleanInstaller
        </CleanDependsOn>
     </PropertyGroup>
  
     <ItemGroup>
		 		<FBBuildScriptFile Include="$(FBScriptFolder)\Build.fbp5" />
		 		<FBInstallerScriptFile Include="$(FBScriptFolder)\Installer.fbp5" />
		
        <SqlProjects Include="$(SqlFolder)\**\*.proj"/>
       
        <Developers Include="
                    developer1@sanlam.co.za;
                  developer2@sanlam.co.za" />        
        <QTPTesters Include=
                    "tester1@sanlam.co.za;
                     tester2@sanlam.co.za" />
					 
		<BuildFilesToDelete Include="$(CodeFolder)\**\*.dcu;
								$(CodeFolder)\**\*.dcp;
								$(CodeFolder)\**\*.map;
								$(CodeFolder)\**\*.dsk;
								$(CodeFolder)\**\*.~*;
								$(CodeFolder)\**\*.bpl;
								$(CodeFolder)\**\*.drc;
								$(OutputPath)\**\*.*" 
					   Exclude="$(OutputPath)\Database\*"/>
					   
		<InstallerFilesToDelete Include="$(InstallerFolder)\Input\*.*;
								$(InstallerFolder)\Output\*.*"/>
					   
	</ItemGroup>



	<Target Name="BuildDatabase">
		<MSBuild Projects="@(SqlProjects)" 
			Targets="Build" 
			Properties="Configuration=$(Configuration);SqlCmdRunner=$(SqlCmdRunner);DBServer=$(DBServer);DBUser=$(DBUser);DBPassword=$(DBPassword);"/>
	</Target>

	<Target Name="BuildReplicador">
		<MSBuild Projects="@(SqlProjects)" 
			Targets="BuildReplicador" 
			Properties="Configuration=$(Configuration);SqlCmdRunner=$(SqlCmdRunner);DBServer=$(DBServer);DBUser=$(DBUser);DBPassword=$(DBPassword);"/>
	</Target>
	
	<Target Name="ExtractDatabase">
		<MSBuild Projects="@(SqlProjects)" 
			Targets="Extract" 
			Properties="Configuration=$(Configuration);SqlCmdRunner=$(SqlCmdRunner);DBServer=$(DBServer);DBUser=$(DBUser);DBPassword=$(DBPassword);"/>
	</Target>

	 <Target Name="CleanDatabase">
		<MSBuild Projects="@(SqlProjects)" 
			Targets="Clean" 
			Properties="Configuration=$(Configuration);Platform=$(Platform);SqlCmdRunner=$(SqlCmdRunner);DBServer=$(DBServer)"/>
	</Target>

	 
   <Target Name="BuildCode">
	  <Exec Command="$(DOUBLE_QUOTES)$(FinalBuilderCmd)$(DOUBLE_QUOTES) /p$(DOUBLE_QUOTES)@(FBBuildScriptFile)$(DOUBLE_QUOTES) /b /c /s" />
   </Target>

   <Target Name="BuildInstaller">
	  <Exec Command="$(DOUBLE_QUOTES)$(FinalBuilderCmd)$(DOUBLE_QUOTES) /p$(DOUBLE_QUOTES)@(FBInstallerScriptFile)$(DOUBLE_QUOTES) /b /c /s" />
   </Target>
	
   <Target Name="CleanCode">
		<Delete Files="@(BuildFilesToDelete)" ContinueOnError="false" />
   </Target>

   <Target Name="CleanInstaller">
		<Delete Files="@(InstallerFilesToDelete)" ContinueOnError="false" />
   </Target>
	
	
	<Target Name="BuildTests">
		<!-- Build the assemblies --> 
		<MSBuild Projects="@(TestProjects)" Targets="$(BuildTargets)" Properties="Configuration=$(Configuration);Platform=$(Platform);RunCodeAnalysis=$(RunCodeAnalysis)"> 
			<Output TaskParameter="TargetOutputs" ItemName="TestAssemblies"/> 
		</MSBuild> 
		<!-- Add the compiled test assemblies to master list of all compiled assemblies for the build --> 
		<CreateItem Include="@(TestAssemblies)"> 
			<Output TaskParameter="Include" ItemName="CompiledAssemblies"/> 
		</CreateItem> 
		<!-- If code analysis was run, create an item collection of the FxCop result files --> 
		<CreateItem Include="%(TestAssemblies.FullPath).$(FxCopFile)" Condition=" '$(RunCodeAnalysis)' == 'true' "> 
			<Output TaskParameter="Include" ItemName="FxCopResults"/> 
		</CreateItem> 
	</Target>	 
	 
	<Target Name="BuildAll"
		DependsOnTargets="BuildDatabase;BuildCode;BuildTests;BuildInstaller"/>
		
	<Target Name="CleanAll"
		DependsOnTargets="CleanDatabase;CleanCode;CleanInstaller"/>

	<Target Name="Rebuild"
		DependsOnTargets="CleanCode;BuildCode"/>
		
	 
	<Target Name="Ayuda">
		<Message Text="Modo de uso:$(NEW_LINE)$(TAB)msbuild /t:nombretarget" />
		<Message Text=" " />

		<Message Text="-> BuildAll" />
	    <Message Text="$(TAB)-> BuildDatabase$(TAB) - Generar la base de datos" />
	    <Message Text="$(TAB)-> BuildCode$(TAB)$(TAB) - Compilar el codigo" />
	    <Message Text="$(TAB)-> BuildTests$(TAB)$(TAB) - Sin uso" />
	    <Message Text="$(TAB)-> BuildInstaller$(TAB)$(TAB) - Generar programa de instalacion" />

		<Message Text=" " />

		<Message Text="-> CleanAll" />
	    <Message Text="$(TAB)-> CleanDatabase$(TAB) - Borrar la base de datos" />
	    <Message Text="$(TAB)-> CleanCode$(TAB)$(TAB) - Borrar todo el codigo compilado (dcu, dcp, bpl y exe)" />
	    <Message Text="$(TAB)-> CleanInstaller$(TAB)$(TAB) - Borrar el instalador generado y todos los ficheros de la aplicacion que contiene" />    
	 
		<Message Text=" " />

		<Message Text="-> Rebuild" />
	    <Message Text="$(TAB)-> CleanCode$(TAB)" />
	    <Message Text="$(TAB)-> BuildCode$(TAB)" />
		
		<Message Text=" " />

		<Message Text="-> ExtractDatabase" />
	    <Message Text="$(TAB)Extrae el metadata de la BD actual y lo deja en un script SQL" />
	    
		<Message Text=" " />

		<Message Text="-> BuildReplicador" />
	    <Message Text="$(TAB)Construye la base de datos para la replicacion e inserta los datos necesarios" />
	</Target> 
	 
</Project>