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