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