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