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