<?xml version="1.0" encoding="utf-8" ?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="MSBuild.Community.Tasks.Targets" />
<PropertyGroup>
<!-- ci root directory -->
<CIPath>c:\_CI\</CIPath>
<!-- used for the application build directory -->
<CITempPath>$(CIPath)Temp\</CITempPath>
<!-- used for the tests build directory and hold the test results -->
<CITestPath>$(CIPath)Test\</CITestPath>
<!-- deployment directories and zip files -->
<CIDeployPath>$(CIPath)Deploy\</CIDeployPath>
<!-- ci source code directories -->
<CISourceCodePath>$(CIPath)Source\</CISourceCodePath>
<!-- TPI source code directories -->
<TPISourceCodePath>$(CISourceCodePath)TPI\</TPISourceCodePath>
<!-- This should be set to true by the CI Server to continue past test errors. This will allow the CI Server to parse and report the test results -->
<MSTestContinueOnError Condition="$(MSTestContinueOnError)==''">false</MSTestContinueOnError>
<!-- full path to svn.exe -->
<SvnExe>C:\Program Files\Subversion\bin\svn.exe</SvnExe>
<!-- full path to mstest.exe -->
<MSTestExe>c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\MSTest.exe</MSTestExe>
</PropertyGroup>
<Target Name="SubversionUpdateTarget" Condition="$(Application) != ''">
<PropertyGroup>
<AppSourceCodePath Condition="$(AppSourceCodePath) == ''">$(CISourceCodePath)$(Application)\</AppSourceCodePath>
</PropertyGroup>
<Exec Command=""$(SvnExe)" update $(AppSourceCodePath)" />
</Target>
<Target Name="MSTestTarget" Condition="$(Application) != ''">
<PropertyGroup>
<AppSourceCodePath Condition="$(AppSourceCodePath) == ''">$(CISourceCodePath)$(Application)\</AppSourceCodePath>
</PropertyGroup>
<!-- get a list of test projects -->
<ItemGroup>
<TestProjects Include="$(AppSourceCodePath)*\**\*.Tests.csproj" />
</ItemGroup>
<!-- delete the previous test output -->
<RemoveDir
Directories="$(CITestPath)\%(TestProjects.Filename)\"
Condition="Exists('$(CITestPath)\%(TestProjects.Filename)\')" />
<!-- build the test projects with the output pointing to the CI test directory -->
<MSBuild
Projects="%(TestProjects.Identity)"
Targets="ReBuild"
Properties="Configuration=Release;OutDir=$(CITestPath)\%(TestProjects.Filename)\"/>
<!-- get a list of test dlls -->
<ItemGroup>
<TestDlls Include="$(CITestPath)$(Application)*\**\*.Tests.dll" />
</ItemGroup>
<Exec
Command=""$(MSTestExe)" /testcontainer:"%(TestDlls.Identity)" /resultsfile:"%(TestDlls.FullPath).xml""
Condition="%(TestDlls.Identity) != ''"
ContinueOnError="$(MSTestContinueOnError)" />
<!-- move the results files into the root CI test directory-->
<Copy
SourceFiles="%(TestDlls.FullPath).xml"
DestinationFolder="$(CITestPath)"
Condition="Exists('%(TestDlls.FullPath).xml')" />
<!-- remove the project test directories -->
<RemoveDir Directories="%(TestDlls.RelativeDir)" />
</Target>
<Target Name="BuildSolutionTarget" Condition="$(Application) != ''">
<PropertyGroup>
<AppSourceCodePath Condition="$(AppSourceCodePath) == ''">$(CISourceCodePath)$(Application)\</AppSourceCodePath>
<AppDeployPath Condition="$(AppDeployPath) == ''">$(CIDeployPath)$(Application)\</AppDeployPath>
<AppTempPath Condition="$(AppTempPath) == ''">$(CITempPath)$(Application)\</AppTempPath>
<DeleteTempDir Condition="$(DeleteTempDir) == ''">true</DeleteTempDir>
</PropertyGroup>
<!-- remove the previous deployment directory -->
<RemoveDir
Directories="$(AppDeployPath)"
Condition="Exists($(AppDeployPath))" />
<!-- rebuild -->
<MSBuild
Projects="$(AppSourceCodePath)$(Application).sln;"
Targets="ReBuild"
Properties="Configuration=Release;WebProjectOutputDir=$(AppDeployPath);OutDir=$(AppTempPath);" />
<CallTarget Targets="RenameConfigFilesTarget" />
<CallTarget Targets="UpdateConfigFilesTarget" />
<CallTarget Targets="RemoveTempDirTarget" Condition="$(AutoDeleteTempDir) == 'true'" />
<CallTarget Targets="CreateZipTarget" />
</Target>
<Target Name="CreateZipTarget" Condition="$(Application) != ''">
<PropertyGroup>
<AppDeployPath Condition="$(AppDeployPath) == ''">$(CIDeployPath)$(Application)\</AppDeployPath>
</PropertyGroup>
<ItemGroup>
<Files Include="$(AppDeployPath)**\*" />
</ItemGroup>
<Zip Files="@(Files)"
ZipFileName="$(CIDeployPath)$(Application).zip"
WorkingDirectory="$(AppDeployPath)"
Condition="%(Files.Identity) != ''" />
</Target>
<Target Name="RemoveTempDirTarget" Condition="$(Application) != ''">
<PropertyGroup>
<AppTempPath Condition="$(AppTempPath) == ''">$(CITempPath)$(Application)\</AppTempPath>
</PropertyGroup>
<!-- delete the build output temp directory -->
<RemoveDir
Directories="$(AppTempPath)"
Condition="Exists('$(AppTempPath)')" />
</Target>
<Target Name="RenameConfigFilesTarget" Condition="$(Application) != ''">
<PropertyGroup>
<AppDeployPath Condition="$(AppDeployPath) == ''">$(CIDeployPath)$(Application)\</AppDeployPath>
<AppTempPath Condition="$(AppTempPath) == ''">$(CITempPath)$(Application)\</AppTempPath>
</PropertyGroup>
<!-- get a list of the config files -->
<ItemGroup>
<!-- web applications build directly into $(AppDeployPath) -->
<ConfigFiles Include="$(AppDeployPath)**\*.config" />
<!-- other applications are build into $(AppTempPath) -->
<ConfigFiles Include="$(AppTempPath)**\*.config" />
<!-- don't rename web.config -->
<ConfigFiles Remove="$(AppDeployPath)**\web.config" />
</ItemGroup>
<Copy
SourceFiles="@(ConfigFiles)"
DestinationFiles="@(ConfigFiles->'%(FullPath).deploy')" />
<Delete Files="@(ConfigFiles)" />
</Target>
<Target Name="UpdateConfigFilesTarget" Condition="$(Application) != ''">
<PropertyGroup>
<AppDeployPath Condition="$(AppDeployPath) == ''">$(CIDeployPath)$(Application)\</AppDeployPath>
</PropertyGroup>
<ItemGroup>
<WebConfigFiles Include="$(AppDeployPath)**\web.config" />
</ItemGroup>
<XmlUpdate
XPath="/configuration/system.web/compilation/@debug"
XmlFileName="%(WebConfigFiles.FullPath)"
Value="false"
Condition="%(WebConfigFiles.Identity) != ''" />
</Target>
</Project>