forked from jamesathey/Core
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathBuild.proj
295 lines (213 loc) · 11.5 KB
/
Build.proj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
<?xml version="1.0" encoding="utf-8"?>
<!--
***********************************************************************************************
Main build script
Copyright 2004-2013 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 "$(MSBuildToolsVersion)" 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 -->
<Message Text="Detected the following test assemblies: @(TestAssemblies)" />
<CreateProperty Value="@(TestAssemblies->'"%(FullPath)"', ' ')">
<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">
<Message Text="Building Solution: $(SolutionPath)" Importance="high"/>
<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/NET40cp" />
<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) != 'SL50' and $(BuildConfigKey) != 'SL40'" />
<CallTarget Targets="_ExecStatLight" Condition="$(BuildConfigKey) == 'SL50' 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>
<CreateProperty Value="v4.0" Condition="'$(TargetFrameworkVersion)' == 'v4.5'">
<Output PropertyName="TargetFrameworkVersion" 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="mono --runtime=v4.0 ../tools/NUnit/bin/nunit-console.exe $(OutputPath)Castle.Core.Tests.dll -nologo -noshadow -xml=$(NUnitTestResultXmlFiles)" Condition=" '$(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>