[xbuild] Microsoft.Common.targets - import Before/After targets files.
[mono.git] / mcs / tools / xbuild / xbuild / 4.0 / Microsoft.Common.targets
1 <Project DefaultTargets="Build" InitialTargets="_ValidateEssentialProperties" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2         <PropertyGroup>
3                 <ImportByWildcardBeforeMicrosoftCommonTargets Condition="'$(ImportByWildcardBeforeMicrosoftCommonTargets)' == ''">true</ImportByWildcardBeforeMicrosoftCommonTargets>
4                 <ImportByWildcardAfterMicrosoftCommonTargets Condition="'$(ImportByWildcardAfterMicrosoftCommonTargets)' == ''">true</ImportByWildcardAfterMicrosoftCommonTargets>
5         </PropertyGroup>
6
7         <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore\*"
8                 Condition="'$(ImportByWildcardBeforeMicrosoftCommonTargets)' == 'true' and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportBefore')"/>
9
10         <PropertyGroup>
11                 <TargetExt Condition="'$(OutputType)' == 'Winexe'">.exe</TargetExt>
12                 <TargetExt Condition="'$(OutputType)' == 'Exe'">.exe</TargetExt>
13                 <TargetExt Condition="'$(OutputType)' == 'Library'">.dll</TargetExt>
14                 <TargetExt Condition="'$(OutputType)' == 'Netmodule'">.netmodule</TargetExt>
15         </PropertyGroup>
16
17         <PropertyGroup>
18                 <ProjectDir Condition="'$(ProjectDir)' == ''">$(MSBuildProjectDirectory)\</ProjectDir>
19         </PropertyGroup>
20
21         <PropertyGroup>
22                 <AssemblyName Condition="'$(AssemblyName)' == ''">$(RootNamespace)</AssemblyName>
23                 <OutputPath Condition="'$(OutputPath)' != '' and !HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath> 
24                 <OutputPath Condition=" '$(Platform)'=='' and '$(Configuration)'=='' and '$(OutputPath)'=='' ">bin\Debug\</OutputPath>
25                 <WarningLevel Condition="'$(WarningLevel)' == ''" >2</WarningLevel>
26
27                 <TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier>
28                 <TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.0</TargetFrameworkVersion>
29
30                 <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == '' and '$(TargetFrameworkProfile)' != ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)</TargetFrameworkMoniker>
31                 <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>
32         </PropertyGroup>
33
34         <PropertyGroup>
35                 <OutDir Condition="'$(OutDir)' == ''">$(OutputPath)</OutDir>
36                 <OutDir Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')">$(OutDir)\</OutDir>
37
38                 <_OriginalConfiguration>$(Configuration)</_OriginalConfiguration>
39                 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
40                 <ConfigurationName Condition="'$(ConfigurationName)' == ''">$(Configuration)</ConfigurationName>
41
42                 <_OriginalPlatform>$(Platform)</_OriginalPlatform>
43                 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
44                 <PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
45
46                 <AddAdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == ''">true</AddAdditionalExplicitAssemblyReferences>
47                 <AdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == 'true' and '$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.0'">System.Core;$(AdditionalExplicitAssemblyReferences)</AdditionalExplicitAssemblyReferences>
48         </PropertyGroup>
49
50         <PropertyGroup>
51                 <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">obj\</BaseIntermediateOutputPath>
52                 <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' != '' and !HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
53                 <CleanFile Condition="'$(CleanFile)'==''">$(MSBuildProjectFile).FilesWrittenAbsolute.txt</CleanFile>
54         </PropertyGroup>
55
56         <PropertyGroup Condition="'$(IntermediateOutputPath)' == ''">
57                 <IntermediateOutputPath Condition=" '$(PlatformName)' == 'AnyCPU'">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
58                 <IntermediateOutputPath Condition=" '$(PlatformName)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
59         </PropertyGroup>
60
61         <PropertyGroup>
62                 <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' != '' and !HasTrailingSlash('$(IntermediateOutputPath)')">$(IntermediateOutputPath)\</IntermediateOutputPath>
63         </PropertyGroup>
64
65         <ItemGroup>
66                 <IntermediateAssembly Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)" />
67
68                 <!-- creating this as a item to use FullPath on it, to build TargetPath -->
69                 <_OutDirItem Include="$(OutDir)"/>
70         </ItemGroup>
71
72         <PropertyGroup>
73                 <TargetName Condition="'$(TargetName)' == '' ">$(AssemblyName)</TargetName>
74                 <TargetFileName Condition="'$(TargetFileName)' == '' ">$(TargetName)$(TargetExt)</TargetFileName>
75                 <TargetDir Condition=" '$(TargetDir)' == '' ">@(_OutDirItem->'%(FullPath)')</TargetDir>
76                 <TargetPath Condition=" '$(TargetPath)' == '' ">@(_OutDirItem->'%(FullPath)\$(TargetFileName)')</TargetPath>
77                 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildProjectFullPath);$(MSBuildToolsPath)\Microsoft.Common.targets</MSBuildAllProjects>
78                 <KeyOriginatorFile Condition=" '$(SignAssembly)' == 'true' ">$(AssemblyOriginatorKeyFile)</KeyOriginatorFile>
79         </PropertyGroup>
80
81         <Target Name="_ValidateEssentialProperties">
82                 <Error Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' != 'true'"
83                         Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
84
85                 <Warning Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' == 'true'"
86                         Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
87
88                 <!-- If OutDir is specified via the command line, then the earlier check
89                      to add a trailing slash won't have any affect, so error here. -->
90                 <Error
91                         Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')"
92                         Text="OutDir property must end with a slash."/>
93         </Target>
94
95         <Target Name="PrepareForBuild">
96                 <Message Importance="High" Text="Configuration: $(Configuration) Platform: $(Platform)"/>
97
98                 <!-- Look for app.config, if $(AppConfig) is specified, then use that. Else look in
99                      @(None) and @(Content) -->
100                 <CreateItem Include="$(AppConfig)" Condition="'$(AppConfig)' != ''"
101                         AdditionalMetadata="TargetPath=$(TargetFileName).config">
102                         <Output TaskParameter="Include" ItemName="AppConfigWithTargetPath" />
103                 </CreateItem>
104
105                 <FindAppConfigFile PrimaryList="@(None)" SecondaryList="@(Content)" TargetPath="$(TargetFileName).config"
106                         Condition="'$(AppConfig)' == ''">
107                         <Output TaskParameter="AppConfigFile" ItemName="AppConfigWithTargetPath"/>
108                 </FindAppConfigFile>
109
110                 <MakeDir 
111                         Directories="$(OutDir);$(IntermediateOutputPath);@(DocFileItem->'%(RelativeDir)')"
112                 />
113         </Target>
114
115         <PropertyGroup>
116                 <GetFrameworkPathsDependsOn />
117         </PropertyGroup>
118         <Target Name="GetFrameworkPaths"
119                 Condition="'$(TargetFrameworkIdentifier)' == '' or '$(TargetFrameworkIdentifier)' == '.NETFramework'"
120                 DependsOnTargets="$(GetFrameworkPathsDependsOn)">
121                 <GetFrameworkPath>
122                         <Output Condition="'$(TargetFrameworkVersion)' == 'v4.0'"
123                                 TaskParameter="FrameworkVersion40Path"
124                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
125                         <Output Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
126                                 TaskParameter="FrameworkVersion35Path"
127                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
128                         <Output Condition="'$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'" 
129                                 TaskParameter="FrameworkVersion30Path"
130                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
131                         <Output Condition="'$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'" 
132                                 TaskParameter="FrameworkVersion20Path"
133                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
134                 </GetFrameworkPath>
135                 <CreateProperty Value="@(_CombinedTargetFrameworkDirectoriesItem)">
136                         <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
137                 </CreateProperty>
138
139                 <Warning Text="TargetFrameworkVersion '$(TargetFrameworkVersion)' not supported by this toolset (ToolsVersion: $(MSBuildToolsVersion))."
140                         Condition="'$(TargetFrameworkVersion)' != 'v4.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v2.0'"/>
141         </Target>
142
143         <PropertyGroup>
144                 <GetReferenceAssemblyPathsDependsOn />
145         </PropertyGroup>
146         <Target Name="GetReferenceAssemblyPaths" DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn)">
147                 <!-- in case of .NETFramework, $(TargetFrameworkDirectory) would have been set by
148                 GetFrameworkPaths, if it hasn't been changed, then clear it, to avoid duplicates -->
149                 <CreateProperty Value="" Condition="'@(_CombinedTargetFrameworkDirectoriesItem)' == '$(TargetFrameworkDirectory)'">
150                         <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
151                 </CreateProperty>
152
153                 <GetReferenceAssemblyPaths
154                         Condition="'$(TargetFrameworkMoniker)' != ''"
155                         TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
156                         RootPath="$(TargetFrameworkRootPath)">
157
158                         <Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
159                         <Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
160                         <Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName"/>
161                 </GetReferenceAssemblyPaths>
162
163                 <CreateProperty Value="$(_TargetFrameworkDirectories);$(TargetFrameworkDirectory)">
164                         <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
165                 </CreateProperty>
166         </Target>
167
168         <PropertyGroup>
169                 <AllowedReferenceAssemblyFileExtensions Condition=" '$(AllowedReferenceAssemblyFileExtensions)' == '' ">
170                         .exe;
171                         .dll
172                 </AllowedReferenceAssemblyFileExtensions>
173
174                 <AllowedReferenceRelatedFileExtensions Condition=" '$(AllowedReferenceRelatedFileExtensions)' == '' ">
175                         .mdb
176                 </AllowedReferenceRelatedFileExtensions>
177
178                 <AssemblySearchPaths Condition="'$(AssemblySearchPaths)' == ''">
179                         {CandidateAssemblyFiles};
180                         $(ReferencePath);
181                         {HintPathFromItem};
182                         {TargetFrameworkDirectory};
183                         {PkgConfig};
184                         {GAC};
185                         {RawFileName};
186                         $(OutDir)
187                 </AssemblySearchPaths>
188
189                 <ResolveReferencesDependsOn>
190                         BeforeResolveReferences;
191                         ResolveProjectReferences;
192                         ResolveAssemblyReferences;
193                         AfterResolveReferences
194                 </ResolveReferencesDependsOn>
195
196                 <ResolveAssemblyReferencesDependsOn>
197                         GetFrameworkPaths;
198                         GetReferenceAssemblyPaths;
199                         PrepareForBuild
200                 </ResolveAssemblyReferencesDependsOn>
201         </PropertyGroup>
202
203         <Target Name="ResolveReferences" DependsOnTargets="$(ResolveReferencesDependsOn)"/>
204
205         <Target Name="BeforeResolveReferences" />
206         <Target Name="AfterResolveReferences" />
207
208         <Target Name="ResolveAssemblyReferences" DependsOnTargets="$(ResolveAssemblyReferencesDependsOn)">
209                 <CreateItem Include="@(Reference)" Exclude="$(AdditionalExplicitAssemblyReferences)">
210                         <Output TaskParameter="Include" ItemName="_Reference"/>
211                 </CreateItem>
212
213                 <CreateItem Include="$(AdditionalExplicitAssemblyReferences)">
214                         <Output TaskParameter="Include" ItemName="_Reference"/>
215                 </CreateItem>
216
217                 <ResolveAssemblyReference
218                         Assemblies="@(_Reference)"
219                         AssemblyFiles="@(ChildProjectReferences)"
220                         SearchPaths="$(AssemblySearchPaths)"
221                         CandidateAssemblyFiles="@(Content);@(None)"
222                         TargetFrameworkDirectories="$(TargetFrameworkDirectory)"
223                         AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)"
224                         AllowedRelatedFileExtensions="$(AllowedReferenceRelatedFileExtensions)"
225                         FindDependencies="true"
226                         FindSatellites="true"
227                         FindRelatedFiles="true"
228                         TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
229                         TargetFrameworkMonikerDisplayName="$(TargetFrameworkMonikerDisplayName)"
230                         TargetFrameworkVersion="$(TargetFrameworkVersion)"
231                 >
232                         <Output TaskParameter="ResolvedFiles" ItemName="ResolvedFiles"/>
233                         <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
234                         <Output TaskParameter="ResolvedDependencyFiles" ItemName="_ResolvedDependencyFiles"/>
235                         <Output TaskParameter="RelatedFiles" ItemName="_ReferenceRelatedPaths"/>
236                         <Output TaskParameter="SatelliteFiles" ItemName="ReferenceSatellitePaths"/>
237                         <Output TaskParameter="CopyLocalFiles" ItemName="ReferenceCopyLocalPaths"/>
238                 </ResolveAssemblyReference>
239         </Target>
240
241         <Target
242                 Name="AssignProjectConfigurations"
243                 Condition="'@(ProjectReference)' != ''">
244
245                 <!-- assign configs if building a solution file -->
246                 <AssignProjectConfiguration
247                         ProjectReferences = "@(ProjectReference)"
248                         SolutionConfigurationContents = "$(CurrentSolutionConfigurationContents)"
249                         Condition="'$(BuildingSolutionFile)' == 'true'">
250
251                         <Output TaskParameter = "AssignedProjects" ItemName = "ProjectReferenceWithConfiguration"/>
252                 </AssignProjectConfiguration>
253
254                 <!-- Else, just -->
255                 <CreateItem Include="@(ProjectReference)" Condition="'$(BuildingSolutionFile)' != 'true'">
256                         <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfiguration"/>
257                 </CreateItem>
258
259         </Target>
260
261         <!-- Split projects into 2 lists
262                 ProjectReferenceWithConfigurationExistent: Projects existent on disk
263                 ProjectReferenceWithConfigurationNonExistent: Projects non-existent on disk -->
264
265         <Target Name="SplitProjectReferencesByExistent"
266                 DependsOnTargets="AssignProjectConfigurations">
267
268                 <CreateItem Include="@(ProjectReferenceWithConfiguration)" Condition="'@(ProjectReferenceWithConfiguration)' != ''">
269                         <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfigurationExistent"
270                                 Condition="Exists ('%(ProjectReferenceWithConfiguration.Identity)')"/>
271
272                         <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfigurationNonExistent"
273                                 Condition="!Exists ('%(ProjectReferenceWithConfiguration.Identity)')"/>
274                 </CreateItem>
275         </Target>
276
277         <Target
278                 Name="ResolveProjectReferences"
279                 DependsOnTargets="SplitProjectReferencesByExistent"
280         >
281                 <!-- If building from a .sln.proj or from IDE, then referenced projects have already
282                      been built, so just get the target paths -->
283                 <MSBuild
284                         Projects="@(ProjectReferenceWithConfigurationExistent)"
285                         Targets="GetTargetPath"
286                         Properties="%(ProjectReferenceWithConfigurationExistent.SetConfiguration); %(ProjectReferenceWithConfigurationExistent.SetPlatform)"
287                         Condition="'@(ProjectReferenceWithConfigurationExistent)' != '' and ('$(BuildingSolutionFile)' == 'true' or '$(BuildingInsideVisualStudio)' == 'true')">
288
289                         <Output TaskParameter="TargetOutputs" ItemName="ChildProjectReferences" />
290                 </MSBuild>
291
292                 <!-- Building a project directly, build the referenced the projects also -->
293                 <MSBuild
294                         Projects="@(ProjectReferenceWithConfigurationExistent)"
295                         Properties="%(ProjectReferenceWithConfigurationExistent.SetConfiguration); %(ProjectReferenceWithConfigurationExistent.SetPlatform)"
296                         Condition="'@(ProjectReferenceWithConfigurationExistent)' != '' and '$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true' ">
297
298                         <Output TaskParameter="TargetOutputs" ItemName="ChildProjectReferences" />
299                 </MSBuild>
300
301                 <Warning Text="Referenced Project %(ProjectReferenceWithConfigurationNonExistent.Identity) not found, ignoring."
302                          Condition="'@(ProjectReferenceWithConfigurationNonExistent)' != ''"/>
303         </Target>
304
305         <Target Name = "CopyFilesMarkedCopyLocal">
306                 <Copy
307                         SourceFiles="@(ReferenceCopyLocalPaths)"
308                         DestinationFiles="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"
309                         SkipUnchangedFiles="true">
310                         <Output TaskParameter = "DestinationFiles" ItemName = "FileWritesShareable"/>
311                 </Copy>
312         </Target>
313
314 <!--
315         Not needed at the moment
316         <Target Name="_ComputeNonExistentFileProperty" Condition='false'>
317                 <CreateProperty Value="__NonExistentSubDir__\__NonExistentFile__">
318                         <Output TaskParameter="Value" PropertyName="NonExistentFile"/>
319                 </CreateProperty>
320         </Target>
321 -->
322
323         <PropertyGroup>
324                 <BuildDependsOn>
325                         BeforeBuild;
326                         CoreBuild;
327                         AfterBuild
328                 </BuildDependsOn>
329         </PropertyGroup>
330
331         <Target Name="BeforeBuild"/>
332         <Target Name="AfterBuild"/>
333
334         <Target Name="Build" DependsOnTargets="$(BuildDependsOn)" Outputs="$(TargetPath)"/>
335
336         <PropertyGroup>
337                 <CoreBuildDependsOn>
338                         PrepareForBuild;
339                         GetFrameworkPaths;
340                         GetReferenceAssemblyPaths;
341                         PreBuildEvent;
342                         ResolveReferences;
343                         CopyFilesMarkedCopyLocal;
344                         PrepareResources;
345                         Compile;
346                         PrepareForRun;
347                         DeployOutputFiles;
348                         _RecordCleanFile;
349                         PostBuildEvent
350                 </CoreBuildDependsOn>
351         </PropertyGroup>
352
353         <Target
354                 Name="CoreBuild"
355                 DependsOnTargets="$(CoreBuildDependsOn)"
356                 Outputs="$(OutDir)$(AssemblyName)$(TargetExt)">
357
358                 <OnError ExecuteTargets="_TimestampAfterCompile;PostBuildEvent"
359                         Condition=" '$(RunPostBuildEvent)' == 'Always' or '$(RunPostBuildEvent)' == 'OnOutputUpdated'"/>
360
361                 <OnError ExecuteTargets="_RecordCleanFile" />
362         </Target>
363
364         <PropertyGroup>
365                 <CompileDependsOn>
366                         ResolveReferences;
367                         BeforeCompile;
368                         _TimestampBeforeCompile;
369                         CoreCompile;
370                         _TimestampAfterCompile;
371                         AfterCompile
372                 </CompileDependsOn>
373         </PropertyGroup>
374
375         <Target Name="BeforeCompile" />
376         <Target Name="AfterCompile" />
377
378         <Target Name="Compile" DependsOnTargets="$(CompileDependsOn)"/>
379
380         <PropertyGroup>
381                 <PrepareForRunDependsOn>
382                         DeployOutputFiles
383                 </PrepareForRunDependsOn>
384         </PropertyGroup>
385         <Target Name="PrepareForRun" DependsOnTargets="$(PrepareForRunDependsOn)"/>
386
387         <PropertyGroup>
388                 <PrepareResourcesDependsOn>
389                         AssignTargetPaths;
390                         SplitResourcesByCulture;
391                         CreateManifestResourceNames;
392                         CopyNonResxEmbeddedResources;
393                         GenerateResources;
394                         GenerateSatelliteAssemblies;
395                         CompileLicxFiles
396                 </PrepareResourcesDependsOn>
397         </PropertyGroup>
398         <Target Name="PrepareResources" DependsOnTargets="$(PrepareResourcesDependsOn)" />
399
400         <Target Name="SplitResourcesByCulture" DependsOnTargets="AssignTargetPaths">
401                 <!-- Extract .licx files into @(LicxFiles) -->
402                 <CreateItem Include="@(EmbeddedResourceWithTargetPath)" Condition="'%(Extension)' == '.licx'">
403                         <Output TaskParameter="Include" ItemName="LicxFiles"/>
404                 </CreateItem>
405
406                 <!-- Split *remaining* resource files into various groups.. -->
407                 <AssignCulture Files="@(EmbeddedResourceWithTargetPath)" Condition="'%(Extension)' != '.licx'">
408                         <Output TaskParameter="AssignedFilesWithNoCulture" ItemName="ResourcesWithNoCulture"/>
409                         <Output TaskParameter="AssignedFilesWithCulture" ItemName="ResourcesWithCulture"/>
410                 </AssignCulture>
411
412                 <CreateItem Include="@(ResourcesWithNoCulture)" Condition="'%(Extension)' == '.resx'">
413                         <Output TaskParameter="Include" ItemName="ResxWithNoCulture"/>
414                 </CreateItem>
415
416                 <CreateItem Include="@(ResourcesWithNoCulture)" Condition="'%(Extension)' != '.resx'">
417                         <Output TaskParameter="Include" ItemName="NonResxWithNoCulture"/>
418                 </CreateItem>
419
420                 <CreateItem Include="@(ResourcesWithCulture)" Condition="'%(Extension)' == '.resx'">
421                         <Output TaskParameter="Include" ItemName="ResxWithCulture"/>
422                 </CreateItem>
423
424                 <CreateItem Include="@(ResourcesWithCulture)" Condition="'%(Extension)' != '.resx'">
425                         <Output TaskParameter="Include" ItemName="NonResxWithCulture"/>
426                 </CreateItem>
427         </Target>
428
429         <!-- Copy non-resx resources to their manifest resource names, this is what the compiler expects -->
430         <Target Name = "CopyNonResxEmbeddedResources"
431                 Condition = "'@(NonResxWithCulture)' != '' or '@(NonResxWithNoCulture)' != '' or '@(ManifestNonResxWithCulture)' != '' or '@(ManifestNonResxWithNoCulture)' != ''">
432
433                 <MakeDir Directories="$(IntermediateOutputPath)%(ManifestNonResxWithCulture.Culture)"/>
434                 <Copy SourceFiles = "@(NonResxWithCulture)"
435                         DestinationFiles = "@(ManifestNonResxWithCulture->'$(IntermediateOutputPath)%(Identity)')"
436                         SkipUnchangedFiles="true">
437                         <Output TaskParameter = "DestinationFiles" ItemName = "ManifestNonResxWithCultureOnDisk"/>
438                         <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
439                 </Copy>
440
441                 <Copy SourceFiles = "@(NonResxWithNoCulture)"
442                         DestinationFiles = "@(ManifestNonResxWithNoCulture->'$(IntermediateOutputPath)%(Identity)')"
443                         SkipUnchangedFiles="true">
444                         <Output TaskParameter = "DestinationFiles" ItemName = "ManifestNonResxWithNoCultureOnDisk"/>
445                         <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
446                 </Copy>
447         </Target>
448
449         <Target Name = "GenerateResources">
450                 <GenerateResource
451                         Sources = "@(ResxWithNoCulture)"
452                         UseSourcePath = "true"
453                         OutputResources = "@(ManifestResourceWithNoCultureName->'$(IntermediateOutputPath)%(Identity).resources')"
454                         Condition = "'@(ResxWithNoCulture)' != '' ">
455
456                         <Output TaskParameter = "OutputResources" ItemName = "ManifestResourceWithNoCulture"/>
457                         <Output TaskParameter = "FilesWritten" ItemName = "FileWrites"/>
458                 </GenerateResource>
459
460                 <GenerateResource
461                         Sources = "@(ResxWithCulture)"
462                         UseSourcePath = "true"
463                         OutputResources = "@(ManifestResourceWithCultureName->'$(IntermediateOutputPath)%(Identity).resources')"
464                         Condition = "'@(ResxWithCulture)' != '' ">
465
466                         <Output TaskParameter = "OutputResources" ItemName = "ManifestResourceWithCulture"/>
467                         <Output TaskParameter = "FilesWritten" ItemName = "FileWrites"/>
468                 </GenerateResource>
469         </Target>
470
471         <Target Name="GenerateSatelliteAssemblies"
472                 Inputs="@(ManifestResourceWithCulture);@(ManifestNonResxWithCultureOnDisk)"
473                 Outputs="$(IntermediateOutputPath)%(Culture)\$(AssemblyName).resources.dll" >
474                 <!-- @(NonResxWithCulture) - rename files to ManifestNon.. and then use for AL -->
475                 <MakeDir Directories = "$(IntermediateOutputPath)%(ManifestResourceWithCulture.Culture)" Condition = "'@(ManifestResourceWithCulture)' != ''" />
476                 <MakeDir Directories = "$(IntermediateOutputPath)%(ManifestNonResxWithCultureOnDisk.Culture)" Condition = "'@(ManifestNonResxWithCultureOnDisk)' != ''" />
477
478                 <AL
479                         Culture = "%(Culture)"
480                         DelaySign="$(DelaySign)"
481                         EmbedResources = "@(ManifestResourceWithCulture);@(ManifestNonResxWithCultureOnDisk)"
482                         KeyFile="$(KeyOriginatorFile)"
483                         ToolExe="$(AlToolExe)"
484                         ToolPath="$(AlToolPath)"
485                         OutputAssembly = "$(IntermediateOutputPath)%(Culture)\$(AssemblyName).resources.dll" >
486                         <Output TaskParameter="OutputAssembly" ItemName="FileWrites"/>
487                 </AL>
488
489
490                 <CreateItem
491                         Include = "$(IntermediateOutputPath)%(Culture)\$(AssemblyName).resources.dll"
492                         AdditionalMetadata = "Culture=%(Culture)"
493                         Condition = "'@(ManifestResourceWithCulture)' != '' or '@(ManifestNonResxWithCultureOnDisk)' != ''">
494                         <Output TaskParameter = "Include" ItemName = "IntermediateSatelliteAssemblies" />
495                 </CreateItem>
496         </Target>
497
498         <PropertyGroup>
499                 <CompileLicxFilesDependsOn></CompileLicxFilesDependsOn>
500         </PropertyGroup>
501
502         <Target Name = "CompileLicxFiles"
503                 Condition = "'@(LicxFiles)' != ''"
504                 DependsOnTargets = "$(CompileLicxFilesDependsOn)"
505                 Outputs = "$(IntermediateOutputPath)$(TargetFileName).licenses">
506                 <LC
507                         Sources = "@(LicxFiles)"
508                         LicenseTarget = "$(TargetFileName)"
509                         OutputDirectory = "$(IntermediateOutputPath)"
510                         OutputLicense = "$(IntermediateOutputPath)$(TargetFileName).licenses"
511                         ReferencedAssemblies = "@(ReferencePath);@(_ResolvedDependencyFiles)"
512                         ToolPath = "$(LCToolPath)"
513                         ToolExe = "$(LCToolExe)">
514
515                         <Output TaskParameter="OutputLicense" ItemName="CompiledLicenseFile"/>
516                         <Output TaskParameter="OutputLicense" ItemName="FileWrites"/>
517                 </LC>
518         </Target>
519
520         <!-- Assign target paths to files that will need to be copied along with the project -->
521         <Target Name = "AssignTargetPaths">
522                 <AssignTargetPath Files="@(None)" RootFolder="$(MSBuildProjectDirectory)">
523                         <Output TaskParameter="AssignedFiles" ItemName="NoneWithTargetPath"/>
524                 </AssignTargetPath>
525
526                 <AssignTargetPath Files="@(Content)" RootFolder="$(MSBuildProjectDirectory)">
527                         <Output TaskParameter="AssignedFiles" ItemName="ContentWithTargetPath"/>
528                 </AssignTargetPath>
529
530                 <AssignTargetPath Files="@(EmbeddedResource)" RootFolder="$(MSBuildProjectDirectory)">
531                         <Output TaskParameter="AssignedFiles" ItemName="EmbeddedResourceWithTargetPath"/>
532                 </AssignTargetPath>
533         </Target>
534
535         <Target Name="DeployOutputFiles"
536                 DependsOnTargets="PrepareResources;CoreCompile;_CopyDeployFilesToOutputDirectory;_CopyAppConfigFile">
537
538                 <Copy 
539                         SourceFiles="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb"
540                         Condition="'$(OutDir)' != '' and Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')"
541                         DestinationFolder="$(OutDir)"
542                         SkipUnchangedFiles="true" >
543                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
544                 </Copy>
545
546                 <Copy SourceFiles="@(IntermediateAssembly)" Condition="'$(OutDir)' != '' and Exists ('@(IntermediateAssembly)')" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true">
547                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
548                 </Copy>
549
550                 <Copy
551                         SourceFiles = "@(IntermediateSatelliteAssemblies)"
552                         DestinationFiles = "@(IntermediateSatelliteAssemblies->'$(OutDir)\%(Culture)\$(AssemblyName).resources.dll')"
553                         Condition = "'@(IntermediateSatelliteAssemblies)' != ''"
554                         SkipUnchangedFiles="true">
555                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
556                 </Copy>
557         </Target>
558
559         <Target Name="_CopyDeployFilesToOutputDirectory"
560                 DependsOnTargets="GetCopyToOutputDirectoryItems;
561                         _CopyDeployFilesToOutputDirectoryAlways;
562                         _CopyDeployFilesToOutputDirectoryPreserveNewest"/>
563
564         <Target Name="_CopyDeployFilesToOutputDirectoryPreserveNewest"
565                 Condition="'@(ItemsToCopyToOutputDirectoryPreserveNewest)' != ''"
566                 Inputs="@(ItemsToCopyToOutputDirectoryPreserveNewest)"
567                 Outputs="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')">
568
569                 <Copy SourceFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest)"
570                         DestinationFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')">
571                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
572                 </Copy>
573         </Target>
574
575         <!-- Copy if newer -->
576         <Target Name="_CopyDeployFilesToOutputDirectoryAlways"
577                 Condition="'@(ItemsToCopyToOutputDirectoryAlways)' != ''">
578
579                 <Copy SourceFiles="@(ItemsToCopyToOutputDirectoryAlways)"
580                         DestinationFiles="@(ItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')">
581                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
582                 </Copy>
583         </Target>
584
585
586         <Target Name="_CopyAppConfigFile" Condition="'@(AppConfigWithTargetPath)' != ''"
587                 Inputs="@(AppConfigWithTargetPath)"
588                 Outputs="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')">
589
590                 <Copy SourceFiles="@(AppConfigWithTargetPath)"
591                         DestinationFiles="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')">
592                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
593                 </Copy>
594         </Target>
595
596         <Target Name="GetTargetPath" Outputs="$(TargetPath)"/>
597
598         <Target Name="GetCopyToOutputDirectoryItems"
599                 Outputs="@(AllItemsFullPathWithTargetPath)"
600                 DependsOnTargets="AssignTargetPaths;SplitProjectReferencesByExistent">
601
602                 <!-- FIXME: handle .vcproj
603                      FIXME: Private ProjectReferences are honored only in 3.5
604                 -->
605                 <MSBuild
606                         Projects="@(ProjectReferenceWithConfigurationExistent)"
607                         Targets="GetCopyToOutputDirectoryItems"
608                         Condition="'@(ProjectReferenceWithConfigurationExistent)' != '' and '%(ProjectReferenceWithConfigurationExistent.Private)' != 'false'">
609
610                         <Output TaskParameter="TargetOutputs" ItemName="AllChildProjectItemsWithTargetPath"/>
611                 </MSBuild>
612
613                 <!-- Process items from child project. The outputs need to have full path
614                      as they'll be used from other projects -->
615
616                 <CreateItem
617                         Include="@(AllChildProjectItemsWithTargetPath->'%(FullPath)')"
618                         Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
619
620                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
621                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
622                                 Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
623                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
624                                 Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
625
626                 </CreateItem>
627
628                 <!-- Process _this_ project's items -->
629
630                 <CreateItem
631                         Include="@(NoneWithTargetPath->'%(FullPath)')"
632                         Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(NoneWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
633                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
634                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
635                                 Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
636                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
637                                 Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
638                 </CreateItem>
639
640                 <CreateItem
641                         Include="@(ContentWithTargetPath->'%(FullPath)')"
642                         Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(ContentWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
643                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
644                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
645                                 Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
646                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
647                                 Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
648                 </CreateItem>
649
650                 <CreateItem
651                         Include="@(EmbeddedResourceWithTargetPath->'%(FullPath)')"
652                         Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
653                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
654                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
655                                 Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
656                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
657                                 Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
658                 </CreateItem>
659
660         </Target>
661
662         <!-- Pre/Post BuildEvents -->
663         <PropertyGroup>
664                 <PreBuildEventDependsOn />
665         </PropertyGroup>
666
667         <Target Name="PreBuildEvent"
668                 Condition="'$(PreBuildEvent)' != ''"
669                 DependsOnTargets="$(PreBuildEventDependsOn)">
670
671                 <Exec WorkingDirectory="$(OutDir)" Command="$(PreBuildEvent)" />
672         </Target>
673
674         <!-- PostBuildEvent depends on $(RunPostBuildEvent)
675
676                 Default: OnBuildSuccess
677                 OnBuildSuccess: Run after a successful build
678                 OnOutputUpdated: Run only if the output assembly got updates
679                 Always: Run always
680         -->
681         <PropertyGroup>
682                 <PostBuildEventDependsOn />
683         </PropertyGroup>
684
685         <!-- this gets invoked in two cases, from CoreBuildDependsOn, if the build completes
686              successfully, OR from OnError in CoreBuild, if the build failed and $(RunPostBuildEvent)
687              is 'Always' or 'OnOutputUpdated'. Invoke $(PostBuildEvent) if its either Empty (== OnBuildSuccess)
688              or OnBuildSuccess or Always OR (OnOutputUpdated and output assembly got updated) -->
689         <Target Name="PostBuildEvent"
690                 Condition="'$(PostBuildEvent)' != '' and
691                         ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or
692                           '$(_AssemblyModifiedTimeBeforeCompile)' != '$(_AssemblyModifiedTimeAfterCompile)')"
693                 DependsOnTargets="$(PostBuildEventDependsOn)">
694
695                 <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
696         </Target>
697
698         <!-- Timestamp the output assemblies, required for PostBuildEvent -->
699         <Target Name="_TimestampBeforeCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
700                 <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
701                         <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeBeforeCompile" />
702                 </CreateItem>
703         </Target>
704         <Target Name="_TimestampAfterCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
705                 <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
706                         <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeAfterCompile" />
707                 </CreateItem>
708         </Target>
709
710         <!-- Rebuild -->
711         <PropertyGroup>
712                 <RebuildDependsOn>
713                         BeforeRebuild;
714                         Clean;
715                         $(MSBuildProjectDefaultTargets);
716                         AfterRebuild;
717                 </RebuildDependsOn>
718
719                 <RebuildDependsOn Condition="'$(MSBuildProjectDefaultTargets)' == 'Rebuild'">
720                         BeforeRebuild;
721                         Clean;
722                         Build;
723                         AfterRebuild;
724                 </RebuildDependsOn>
725         </PropertyGroup>
726
727         <Target Name="BeforeRebuild" />
728         <Target Name="AfterRebuild" />
729
730         <Target Name="Rebuild"
731                 DependsOnTargets="$(RebuildDependsOn)"
732                 Outputs="$(TargetPath)"/>
733
734         <!-- Clean -->
735         <Target Name="_RecordCleanFile"
736                 DependsOnTargets="_GetCompileOutputsForClean">
737
738                 <!-- add to list of previous writes for this platform/config -->
739
740                 <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
741                         <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
742                 </ReadLinesFromFile>
743
744                 <RemoveDuplicates Inputs="@(PreviousFileWrites);@(FileWrites->'%(FullPath)')">
745                         <Output TaskParameter="Filtered" ItemName="CombinedFileWrites"/>
746                 </RemoveDuplicates>
747
748                 <!-- CopyLocal files: In case all the projects build to common output
749                      directory, then other projects might depend on some of these
750                      CopyLocal files, so delete only the ones under *this* project
751                      directory -->
752                 <FindUnderPath Path="$(MSBuildProjectDirectory)" Files="@(FileWritesShareable)">
753                         <Output TaskParameter="InPath" ItemName="FileWrites"/>
754                 </FindUnderPath>
755
756                 <WriteLinesToFile
757                         File="$(IntermediateOutputPath)$(CleanFile)"
758                         Lines="@(CombinedFileWrites)"
759                         Overwrite="true"/>
760         </Target>
761
762         <PropertyGroup>
763                 <CleanDependsOn>
764                         BeforeClean;
765                         CleanReferencedProjects;
766                         CoreClean;
767                         AfterClean
768                 </CleanDependsOn>
769         </PropertyGroup>
770
771         <Target Name="_GetCompileOutputsForClean">
772                 <!-- assembly and debug file in the *intermediate output path* -->
773                 <CreateItem Include="@(IntermediateAssembly)" Condition="Exists('@(IntermediateAssembly)')">
774                         <Output TaskParameter="Include" ItemName="FileWrites"/>
775                 </CreateItem>
776
777                 <CreateItem Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb"
778                         Condition="Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')">
779                         <Output TaskParameter="Include" ItemName="FileWrites"/>
780                 </CreateItem>
781         </Target>
782
783         <!-- Get the list of files written, for clean -->
784         <Target Name="_GetCleanFileWrites"
785                 DependsOnTargets="_GetCompileOutputsForClean">
786                 <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
787                         <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
788                 </ReadLinesFromFile>
789         </Target>
790
791         <Target Name="CleanReferencedProjects"
792                 DependsOnTargets="AssignProjectConfigurations">
793
794                 <!-- If building from .sln.proj or from IDE, clean will get handled by them,
795                      else we are building a project directly, from the command line, so
796                      clean the referenced projects -->
797                 <MSBuild Projects="@(ProjectReferenceWithConfigurationExistent)"
798                         Targets="Clean"
799                         Condition=" '$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true' and '@(ProjectReferenceWithConfigurationExistent)' != ''" />
800
801         </Target>
802
803         <Target Name="Clean" DependsOnTargets="$(CleanDependsOn)"/>
804
805         <!-- Override in project to run before/after clean tasks -->
806         <Target Name="BeforeClean" />
807         <Target Name="AfterClean" />
808
809         <Target Name="CoreClean" DependsOnTargets="_GetCleanFileWrites">
810                 <Delete Files="@(PreviousFileWrites);@(FileWrites)" TreatErrorsAsWarnings="true"/>
811
812                 <!-- all previous files written for this platform/config have been deleted,
813                      we can safely remove the file list now -->
814                 <Delete Files="$(IntermediateOutputPath)$(CleanFile)" TreatErrorsAsWarnings="true" />
815         </Target>
816
817         <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter\*"
818                 Condition="'$(ImportByWildcardAfterMicrosoftCommonTargets)' == 'true' and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter')"/>
819 </Project>