Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

299 lines (216 sloc) 12.074 kB
<?xml version="1.0" encoding="utf-8"?>
<!--
***********************************************************************************************
Main build script
Copyright 2004-2010 Castle Project - http://www.castleproject.org/
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 DefaultTargets="BuildProject" InitialTargets="CheckRequiredProperties" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<!-- Root Path definition relative for actual build file -->
<PropertyGroup>
<RootPath Condition="'$(RootPath)' == ''">$(MSBuildProjectDirectory)/..</RootPath>
</PropertyGroup>
<!-- Import common targets -->
<Import Project="$(RootPath)/Settings.proj" />
<Import Project="$(BuildScriptsPath)/Castle.Common.Targets" />
<Import Project="$(MSBuildBinPath)/Microsoft.CSharp.Targets" Condition="($(MSBuildTargets) == '') Or ($(MSBuildTargets) == 'CSharp')" />
<Target Name="CheckRequiredProperties">
<Error Condition="'$(ProjectName)' == ''" Text="The ProjectName property has not been set, please set it in Settings.proj." />
<Error Text="The tools version &quot;$(MSBuildToolsVersion)&quot; is not supported, MSBuild 4.0 or newer is required to build." Condition="'$(MSBuildToolsVersion)' != '4.0'" />
<Error Condition="'$(Project_Major)' == ''" Text="The Project_Major property has not been set, please set it in Settings.proj." />
<Error Condition="'$(Project_Minor)' == ''" Text="The Project_Minor property has not been set, please set it in Settings.proj." />
<Error Condition="'$(Project_Build)' == ''" Text="The Project_Build property has not been set, please set it in Settings.proj." />
</Target>
<!--
Public targets
-->
<Target
Name="BuildProject"
>
<MSBuild Projects="$(SolutionPath)" Targets="Build" Properties="OutputPath=$(OutputPath);Configuration=$(Configuration);BuildConstants=$(BuildConstants);MSBuildTargets=$(MSBuildTargets);TargetFrameworkVersion=$(TargetFrameworkVersion)">
<Output TaskParameter="TargetOutputs" ItemName="AllBinaries" />
</MSBuild>
<Message Text="Binaries built from solution: @(AllBinaries)" />
<!-- Resolve test projects -->
<RegexMatch Input="@(AllBinaries)" Expression="$(TestDetectionExpression)">
<Output TaskParameter="Output" ItemName="TestAssemblies" />
</RegexMatch>
<Message Text="Detected the following test assemblies: @(TestAssemblies)" />
<CreateProperty Value="@(TestAssemblies->'&quot;%(FullPath)&quot;', ' ')">
<Output PropertyName="TestAssemblies" TaskParameter="Value"/>
</CreateProperty>
<Message Text="Test assemblies transformed to quoted list: $(TestAssemblies)" />
<!-- Resolve the libraries code projects -->
<CreateItem
Include="@(AllBinaries)"
Exclude="@(TestAssemblies)">
<Output TaskParameter="Include" ItemName="AppAssemblies"/>
</CreateItem>
<!-- Pick up the PDB files. This is kind of hard coded to the location of the AppAssemblies, but I currently don't see another way -->
<CreateItem
Include="@(AppAssemblies->'%(RelativeDir)%(FileName).pdb')">
<Output TaskParameter="Include" ItemName="PdbFiles"/>
</CreateItem>
<!-- Pick up the documentation XML. This is kind of hard coded to the location of the AppAssemblies, but I currently don't see another way -->
<CreateItem
Include="@(AppAssemblies->'%(RelativeDir)%(FileName).xml')"
Condition="Exists('%(AppAssemblies.RelativeDir)%(AppAssemblies.FileName).xml')">
<Output TaskParameter="Include" ItemName="DocumentationFiles"/>
</CreateItem>
</Target>
<Target Name="RebuildAll" DependsOnTargets="CleanAll;BuildProject" />
<Target Name="ClickToBuild" DependsOnTargets="RebuildAll;_PreparePackage">
<RemoveDir Directories="$(OutputPath)" />
</Target>
<Target Name="CleanAll">
<MSBuild Projects="$(SolutionPath)" Targets="Clean" Properties="Configuration=$(Configuration);BuildConstants=$(BuildConstants);MSBuildTargets=$(MSBuildTargets);TargetFrameworkVersion=$(TargetFrameworkVersion)" />
<CreateItem Include="**/Debug/**/*.*;**/Release/**/*.*">
<Output ItemName="_binaryFiles" TaskParameter="Include"/>
</CreateItem>
<Delete Files="@(_binaryFiles)" TreatErrorsAsWarnings="true"/>
<Exec Command="for /f %%d in ('dir /ad /b') do rd /s /q %%d"
WorkingDirectory="$(BuildPath)"
Condition=" Exists('$(BuildPath)') "/>
<RemoveDir Directories="$(BuildPath)" Condition=" Exists('$(BuildPath)') "/>
</Target>
<Target
Name="RunAllTests"
DependsOnTargets="BuildProject"
>
<CallTarget Targets="_ExecTestRunner" />
</Target>
<!-- Creates Zip file for Release -->
<Target
Name="Package"
DependsOnTargets="RunAllTests;_PreparePackage"
>
<CreateProperty Value="$(ProjectName)-$(BuildConfigKey)-$(Build_Number).zip" Condition="'$(Build_ZipFile)' == ''">
<Output PropertyName="Build_ZipFile" TaskParameter="Value"/>
</CreateProperty>
<CreateProperty Value="$(OutputPath)../$(Build_ZipFile)" Condition="'$(Build_ZipFilePath)' == ''">
<Output PropertyName="Build_ZipFilePath" TaskParameter="Value"/>
</CreateProperty>
<Message Importance="high" Text="Creating ZIP file $(Build_ZipFilePath)"/>
<CreateItem Include="$(PackageDir)\**\*.*" Exclude="$(PackageDir)\**\*Tests*">
<Output ItemName="FilesToPackage" TaskParameter="Include" />
</CreateItem>
<Zip
Files="@(FilesToPackage)"
ZipLevel="6"
WorkingDirectory="$(PackageDir)"
ZipFileName="$(Build_ZipFilePath)"
/>
<Message Text="##teamcity[publishArtifacts '$(Build_ZipFilePath)']" Condition="$(TEAMCITY_VERSION) != ''" />
<RemoveDir Directories="$(PackageDir)" ContinueOnError="true" />
</Target>
<Target
Name="NuSpec"
>
<CreateProperty Value="$(BuildPath)/NuSpec">
<Output PropertyName="NuSpecDir" TaskParameter="Value"/>
</CreateProperty>
<MakeDir Directories="$(NuSpecDir)/lib/NET35" />
<MakeDir Directories="$(NuSpecDir)/lib/NET40ClientProfile" />
<MakeDir Directories="$(NuSpecDir)/lib/SL3" />
<MakeDir Directories="$(NuSpecDir)/lib/SL4" />
<CreateProperty Value="$(NuSpecDir)/$(ProjectName).nuspec">
<Output PropertyName="NuSpecFile" TaskParameter="Value"/>
</CreateProperty>
<Copy SourceFiles="nuspec.tmpl" DestinationFiles="$(NuSpecFile)" />
<FileUpdate Files="$(NuSpecFile)" Regex="\$\(Id\)" ReplacementText="$(ProjectName)" />
<FileUpdate Files="$(NuSpecFile)" Regex="\$\(Version\)" ReplacementText="$(Project_Major).$(Project_Minor).$(Project_Build)" />
<FileUpdate Files="$(NuSpecFile)" Regex="\$\(Title\)" ReplacementText="$(ProjectName)" />
<FileUpdate Files="$(NuSpecFile)" Regex="\$\(Description\)" ReplacementText="DynamicProxy, Logging, and Dictionary Adapter components" />
<FileUpdate Files="$(NuSpecFile)" Regex="\$\(Summary\)" ReplacementText="Castle Project core components" />
<FileUpdate Files="$(NuSpecFile)" Regex="\$\(IconUrl\)" ReplacementText="http://www.castleproject.org/images/cp_logo32.png" />
<FileUpdate Files="$(NuSpecFile)" Regex="\$\(Modified\)" ReplacementText='$([System.DateTime]::UtcNow.ToString(""s""))Z' />
</Target>
<!--
==================================================
Internal targets
==================================================
-->
<Target
Name="_ExecTestRunner"
Condition="$(TestRunner_Enabled)"
>
<CallTarget Targets="_ExecNUnit" Condition="$(BuildConfigKey) != 'SL30' and $(BuildConfigKey) != 'SL40'" />
<CallTarget Targets="_ExecStatLight" Condition="$(BuildConfigKey) == 'SL30' or $(BuildConfigKey) == 'SL40'" />
</Target>
<!-- Use TeamCity's when running on the build server -->
<UsingTask TaskName="NUnitTeamCity" AssemblyFile="$(teamcity_dotnet_nunitlauncher_msbuild_task)" Condition=" '$(teamcity_dotnet_nunitlauncher_msbuild_task)' != '' "/>
<Target
Name="_ExecNUnit"
>
<MakeDir Directories="$(TestResultsPath)" Condition="'$(TestResultsPath)' != '' And !Exists('$(TestResultsPath)')" />
<CreateProperty Value="$(TestResultsPath)/nunit-results.xml" Condition="'$(NUnitTestResultXmlFiles)' == ''">
<Output PropertyName="NUnitTestResultXmlFiles" TaskParameter="Value"/>
</CreateProperty>
<Message Text="Running tests from assemblies: $(TestAssemblies)" />
<Exec Command="$(NUnitPath)$(NUnitExecutable) /nologo $(TestAssemblies) /xml=$(NUnitTestResultXmlFiles) /framework=$(TargetFrameworkVersion)" Condition=" '$(TEAMCITY_VERSION)' == '' and '$(OS)' == 'Windows_NT' " />
<Exec Command="$(MonoShell) $(NUnitPath)$(NUnitExecutable) $(OutputPath)Castle.Core.Tests.dll -nologo -xml=$(NUnitTestResultXmlFiles)" Condition=" '$(OS)' != 'Windows_NT' " />
<!-- TC NUnit launcher crashes on 64bit Linux with Mono
<Exec Command="$(MonoShell) S(teamcity_dotnet_nunitlauncher) mono-2.0 x86 NUnit-2.5.5 $(OutputPath)Castle.Core.Tests.dll" Condition=" '$(TEAMCITY_VERSION)' != '' and '$(OS)' != 'Windows_NT' " />
-->
<NUnitTeamCity
Assemblies="@(TestAssemblies)"
NUnitVersion="NUnit-2.5.5"
Condition=" '$(teamcity_dotnet_nunitlauncher_msbuild_task)' != ''"
/>
</Target>
<Target
Name="_ExecStatLight"
>
<CreateProperty Value='$(ToolsPath)\StatLight\StatLight.exe -b -x="$(OutputPath)Castle.Core.Tests.xap" -o=NUnit'>
<Output PropertyName="StatLightCmdLine" TaskParameter="Value"/>
</CreateProperty>
<CreateProperty Value='$(StatLightCmdLine) --teamcity' Condition=" '$(TEAMCITY_VERSION)' != '' ">
<Output PropertyName="StatLightCmdLine" TaskParameter="Value"/>
</CreateProperty>
<Exec Command="$(StatLightCmdLine)" />
</Target>
<!-- Prepare package directory -->
<Target Name="_PreparePackage">
<CreateProperty Value="$(OutputPath)../pkg" Condition="'$(PackageDir)' == ''">
<Output PropertyName="PackageDir" TaskParameter="Value"/>
</CreateProperty>
<RemoveDir Directories="$(PackageDir)" ContinueOnError="true" />
<!-- Grab all Castle assemblies, but ignore unit test assemblies. -->
<CreateItem Include="$(OutputPath)Castle.*.dll;$(OutputPath)Castle.*.xml" Exclude="$(OutputPath)Castle*.Tests.dll">
<Output TaskParameter="Include" ItemName="_CastleDependencies"/>
</CreateItem>
<!-- Create list with items to be copied to package directory. The metadata <DestinationFolder> controls where they wind up. -->
<CreateItem
Include="$(BuildScriptsPath)/*.txt"
AdditionalMetadata="DestinationFolder=$(PackageDir)">
<Output TaskParameter="Include" ItemName="CopyToPackageDirectory"/>
</CreateItem>
<CreateItem
Include="@(AppAssemblies);@(PdbFiles);@(DocumentationFiles);@(_CastleDependencies);@(PackageFiles)"
AdditionalMetadata="DestinationFolder=$(PackageDir)/bin">
<Output TaskParameter="Include" ItemName="CopyToPackageDirectory"/>
</CreateItem>
<CreateItem
Include="$(RootPath)/*.txt"
AdditionalMetadata="DestinationFolder=$(PackageDir)/ReleaseNotes">
<Output TaskParameter="Include" ItemName="CopyToPackageDirectory"/>
</CreateItem>
<CreateItem
Exclude="@(ExcludeFromPackageFiles)">
<Output TaskParameter="Include" ItemName="CopyToPackageDirectory"/>
</CreateItem>
<Copy
SourceFiles="@(CopyToPackageDirectory)"
DestinationFiles="@(CopyToPackageDirectory->'%(DestinationFolder)/%(RecursiveDir)%(Filename)%(Extension)')"
/>
</Target>
</Project>
Jump to Line
Something went wrong with that request. Please try again.