Merge pull request #2354 from xmcclure/ugh-no-gdi
[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                 <WarningLevel Condition="'$(WarningLevel)' == ''" >2</WarningLevel>
34
35                 <TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier>
36                 <TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.0</TargetFrameworkVersion>
37
38                 <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == '' and '$(TargetFrameworkProfile)' != ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)</TargetFrameworkMoniker>
39                 <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>
40         </PropertyGroup>
41
42         <PropertyGroup>
43                 <OutDir Condition="'$(OutDir)' == ''">$(OutputPath)</OutDir>
44                 <OutDir Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')">$(OutDir)\</OutDir>
45
46                 <_OriginalConfiguration>$(Configuration)</_OriginalConfiguration>
47                 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
48                 <ConfigurationName Condition="'$(ConfigurationName)' == ''">$(Configuration)</ConfigurationName>
49
50                 <_OriginalPlatform>$(Platform)</_OriginalPlatform>
51                 <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
52                 <PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
53
54                 <AddAdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == ''">true</AddAdditionalExplicitAssemblyReferences>
55                 <AdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == 'true' and '$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.0'">System.Core;$(AdditionalExplicitAssemblyReferences)</AdditionalExplicitAssemblyReferences>
56         </PropertyGroup>
57
58         <PropertyGroup>
59                 <SkipCopyUnchangedFiles Condition="'$(SkipCopyUnchangedFiles)' == ''">true</SkipCopyUnchangedFiles>
60         </PropertyGroup>
61
62         <PropertyGroup>
63                 <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">obj\</BaseIntermediateOutputPath>
64                 <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' != '' and !HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
65                 <CleanFile Condition="'$(CleanFile)'==''">$(MSBuildProjectFile).FilesWrittenAbsolute.txt</CleanFile>
66         </PropertyGroup>
67
68         <PropertyGroup Condition="'$(IntermediateOutputPath)' == ''">
69                 <IntermediateOutputPath Condition=" '$(PlatformName)' == 'AnyCPU'">$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>
70                 <IntermediateOutputPath Condition=" '$(PlatformName)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
71         </PropertyGroup>
72
73         <PropertyGroup>
74                 <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' != '' and !HasTrailingSlash('$(IntermediateOutputPath)')">$(IntermediateOutputPath)\</IntermediateOutputPath>
75         </PropertyGroup>
76
77         <ItemGroup>
78                 <IntermediateAssembly Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)" />
79
80                 <!-- creating this as a item to use FullPath on it, to build TargetPath -->
81                 <_OutDirItem Include="$(OutDir)"/>
82         </ItemGroup>
83
84         <PropertyGroup>
85                 <TargetName Condition="'$(TargetName)' == '' ">$(AssemblyName)</TargetName>
86                 <TargetFileName Condition="'$(TargetFileName)' == '' ">$(TargetName)$(TargetExt)</TargetFileName>
87                 <TargetDir Condition=" '$(TargetDir)' == '' ">@(_OutDirItem->'%(FullPath)')</TargetDir>
88                 <TargetPath Condition=" '$(TargetPath)' == '' ">@(_OutDirItem->'%(FullPath)\$(TargetFileName)')</TargetPath>
89                 <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildProjectFullPath);$(MSBuildToolsPath)\Microsoft.Common.targets</MSBuildAllProjects>
90                 <KeyOriginatorFile Condition=" '$(SignAssembly)' == 'true' ">$(AssemblyOriginatorKeyFile)</KeyOriginatorFile>
91                 <TargetingClr2Framework Condition="('$(TargetFrameworkIdentifier)' == '.NETFramework') and ('$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5')">true</TargetingClr2Framework>
92         </PropertyGroup>
93
94         <Target Name="_ValidateEssentialProperties">
95                 <Error Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' != 'true'"
96                         Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
97
98                 <Warning Condition=" '$(OutputPath)' == '' and '$(SkipInvalidConfigurations)' == 'true'"
99                         Text="'OutputPath' property is not set for this project. Usually this is caused by invalid Configuration/Platform combination. Original values: Configuration: $(_OriginalConfiguration) Platform: $(_OriginalPlatform)."/>
100
101                 <!-- If OutDir is specified via the command line, then the earlier check
102                      to add a trailing slash won't have any affect, so error here. -->
103                 <Error
104                         Condition="'$(OutDir)' != '' and !HasTrailingSlash('$(OutDir)')"
105                         Text="OutDir property must end with a slash."/>
106         </Target>
107
108         <Target Name="PrepareForBuild">
109                 <Message Importance="High" Text="Configuration: $(Configuration) Platform: $(Platform)"/>
110
111                 <!-- Look for app.config, if $(AppConfig) is specified, then use that. Else look in
112                      @(None) and @(Content) -->
113                 <CreateItem Include="$(AppConfig)" Condition="'$(AppConfig)' != ''"
114                         AdditionalMetadata="TargetPath=$(TargetFileName).config">
115                         <Output TaskParameter="Include" ItemName="AppConfigWithTargetPath" />
116                 </CreateItem>
117
118                 <FindAppConfigFile PrimaryList="@(None)" SecondaryList="@(Content)" TargetPath="$(TargetFileName).config"
119                         Condition="'$(AppConfig)' == ''">
120                         <Output TaskParameter="AppConfigFile" ItemName="AppConfigWithTargetPath"/>
121                 </FindAppConfigFile>
122
123                 <MakeDir
124                         Directories="$(OutDir);$(IntermediateOutputPath);@(DocFileItem->'%(RelativeDir)')"
125                 />
126         </Target>
127
128         <PropertyGroup>
129                 <GetFrameworkPathsDependsOn />
130         </PropertyGroup>
131         <Target Name="GetFrameworkPaths"
132                 Condition="'$(TargetFrameworkIdentifier)' == '' or '$(TargetFrameworkIdentifier)' == '.NETFramework'"
133                 DependsOnTargets="$(GetFrameworkPathsDependsOn)">
134                 <GetFrameworkPath>
135                         <Output Condition="'$(TargetFrameworkVersion)' == 'v4.5' and '$(TargetFrameworkVersion)' == 'v4.5.1'"
136                                 TaskParameter="FrameworkVersion45Path"
137                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
138                         <Output Condition="'$(TargetFrameworkVersion)' == 'v4.0'"
139                                 TaskParameter="FrameworkVersion40Path"
140                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
141                         <Output Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
142                                 TaskParameter="FrameworkVersion35Path"
143                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
144                         <Output Condition="'$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'"
145                                 TaskParameter="FrameworkVersion30Path"
146                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
147                         <Output Condition="'$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'"
148                                 TaskParameter="FrameworkVersion20Path"
149                                 ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
150                 </GetFrameworkPath>
151                 <CreateProperty Value="@(_CombinedTargetFrameworkDirectoriesItem)">
152                         <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
153                 </CreateProperty>
154
155                 <Warning Text="TargetFrameworkVersion '$(TargetFrameworkVersion)' not supported by this toolset (ToolsVersion: $(MSBuildToolsVersion))."
156                         Condition="'$(TargetFrameworkVersion)' != 'v4.5.1' and '$(TargetFrameworkVersion)' != 'v4.5' and '$(TargetFrameworkVersion)' != 'v4.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v2.0'"/>
157         </Target>
158
159         <PropertyGroup>
160                 <GetReferenceAssemblyPathsDependsOn />
161         </PropertyGroup>
162         <Target Name="GetReferenceAssemblyPaths" DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn)">
163                 <!-- in case of .NETFramework, $(TargetFrameworkDirectory) would have been set by
164                 GetFrameworkPaths, if it hasn't been changed, then clear it, to avoid duplicates -->
165                 <CreateProperty Value="" Condition="'@(_CombinedTargetFrameworkDirectoriesItem)' == '$(TargetFrameworkDirectory)'">
166                         <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
167                 </CreateProperty>
168
169                 <GetReferenceAssemblyPaths
170                         Condition="'$(TargetFrameworkMoniker)' != '' and '$(_TargetFrameworkDirectories)' == ''"
171                         TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
172                         RootPath="$(TargetFrameworkRootPath)">
173
174                         <Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
175                         <Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
176                         <Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName"/>
177                 </GetReferenceAssemblyPaths>
178
179
180                 <!-- Remove duplicates. -->
181                 <ItemGroup>
182                         <_TargetFrameworkDirectories Include="$(_TargetFrameworkDirectories);$(TargetFrameworkDirectory)" KeepDuplicates="false" />
183                 </ItemGroup>
184                 <PropertyGroup>
185                         <TargetFrameworkDirectory>@(_TargetFrameworkDirectories)</TargetFrameworkDirectory>
186                 </PropertyGroup>
187
188                 <ItemGroup Condition="'$(ImplicitlyExpandDesignTimeFacades)' == 'true'">
189                         <DesignTimeFacadeDirectoryRoots Include="$(TargetFrameworkDirectory)" />
190                         <DesignTimeFacadeDirectories Include="%(DesignTimeFacadeDirectoryRoots.Identity)\Facades\" Condition="Exists('%(DesignTimeFacadeDirectoryRoots.Identity)\Facades\')" />
191                         <_DesignTimeFacadeAssemblies Include="%(DesignTimeFacadeDirectories.Identity)\*.dll"/>
192                 </ItemGroup>
193
194                 <PropertyGroup Condition="'@(DesignTimeFacadeDirectories)' != ''">
195                         <TargetFrameworkDirectory>$(TargetFrameworkDirectory);@(DesignTimeFacadeDirectories)</TargetFrameworkDirectory>
196                 </PropertyGroup>
197
198         </Target>
199
200         <PropertyGroup>
201                 <AllowedReferenceAssemblyFileExtensions Condition=" '$(AllowedReferenceAssemblyFileExtensions)' == '' ">
202                         .exe;
203                         .dll
204                 </AllowedReferenceAssemblyFileExtensions>
205
206                 <AllowedReferenceRelatedFileExtensions Condition=" '$(AllowedReferenceRelatedFileExtensions)' == '' ">
207                         .exe.mdb;
208                         .dll.mdb;
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 SourceFiles="@(IntermediateAssembly)" Condition="'$(OutDir)' != '' and Exists ('@(IntermediateAssembly)')" DestinationFolder="$(OutDir)" SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
615                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
616                 </Copy>
617
618                 <Copy
619                         SourceFiles = "@(IntermediateSatelliteAssemblies)"
620                         DestinationFiles = "@(IntermediateSatelliteAssemblies->'$(OutDir)\%(Culture)\$(AssemblyName).resources.dll')"
621                         Condition = "'@(IntermediateSatelliteAssemblies)' != ''"
622                         SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
623                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
624                 </Copy>
625         </Target>
626
627         <Target Name="_CopyDeployFilesToOutputDirectory"
628                 DependsOnTargets="GetCopyToOutputDirectoryItems;
629                         _CopyDeployFilesToOutputDirectoryAlways;
630                         _CopyDeployFilesToOutputDirectoryPreserveNewest"/>
631
632         <Target Name="_CopyDeployFilesToOutputDirectoryPreserveNewest"
633                 Condition="'@(ItemsToCopyToOutputDirectoryPreserveNewest)' != ''"
634                 Inputs="@(ItemsToCopyToOutputDirectoryPreserveNewest)"
635                 Outputs="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')">
636
637                 <Copy SourceFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest)"
638                         DestinationFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')"
639                         SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
640                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
641                 </Copy>
642         </Target>
643
644         <!-- Copy if newer -->
645         <Target Name="_CopyDeployFilesToOutputDirectoryAlways"
646                 Condition="'@(ItemsToCopyToOutputDirectoryAlways)' != ''">
647
648                 <Copy SourceFiles="@(ItemsToCopyToOutputDirectoryAlways)"
649                         DestinationFiles="@(ItemsToCopyToOutputDirectoryAlways->'$(OutDir)%(TargetPath)')">
650                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
651                 </Copy>
652         </Target>
653
654
655         <Target Name="_CopyAppConfigFile" Condition="'@(AppConfigWithTargetPath)' != ''"
656                 Inputs="@(AppConfigWithTargetPath)"
657                 Outputs="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')">
658
659                 <Copy SourceFiles="@(AppConfigWithTargetPath)"
660                         DestinationFiles="@(AppConfigWithTargetPath->'$(OutDir)%(TargetPath)')">
661                         <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
662                 </Copy>
663         </Target>
664
665         <Target Name="GetTargetPath" Outputs="$(TargetPath)"/>
666
667         <Target Name="GetCopyToOutputDirectoryItems"
668                 Outputs="@(AllItemsFullPathWithTargetPath)"
669                 DependsOnTargets="AssignTargetPaths;SplitProjectReferencesByExistent">
670
671                 <!-- FIXME: handle .vcproj
672                      FIXME: Private ProjectReferences are honored only in 3.5
673                 -->
674                 <MSBuild
675                         Projects="@(ProjectReferenceWithConfigurationExistent)"
676                         Targets="GetCopyToOutputDirectoryItems"
677                         Condition="'@(ProjectReferenceWithConfigurationExistent)' != '' and '%(ProjectReferenceWithConfigurationExistent.Private)' != 'false'">
678
679                         <Output TaskParameter="TargetOutputs" ItemName="AllChildProjectItemsWithTargetPath"/>
680                 </MSBuild>
681
682                 <!-- Process items from child project. The outputs need to have full path
683                      as they'll be used from other projects -->
684
685                 <CreateItem
686                         Include="@(AllChildProjectItemsWithTargetPath->'%(FullPath)')"
687                         Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
688
689                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
690                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
691                                 Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
692                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
693                                 Condition="'%(AllChildProjectItemsWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
694
695                 </CreateItem>
696
697                 <!-- Process _this_ project's items -->
698
699                 <CreateItem
700                         Include="@(NoneWithTargetPath->'%(FullPath)')"
701                         Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(NoneWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
702                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
703                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
704                                 Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
705                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
706                                 Condition="'%(NoneWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
707                 </CreateItem>
708
709                 <CreateItem
710                         Include="@(ContentWithTargetPath->'%(FullPath)')"
711                         Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(ContentWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
712                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
713                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
714                                 Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
715                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
716                                 Condition="'%(ContentWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
717                 </CreateItem>
718
719                 <CreateItem
720                         Include="@(EmbeddedResourceWithTargetPath->'%(FullPath)')"
721                         Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)' == 'Always' or '%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)' == 'PreserveNewest'">
722                         <Output TaskParameter="Include" ItemName="AllItemsFullPathWithTargetPath"/>
723                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryAlways"
724                                 Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='Always'"/>
725                         <Output TaskParameter="Include" ItemName="ItemsToCopyToOutputDirectoryPreserveNewest"
726                                 Condition="'%(EmbeddedResourceWithTargetPath.CopyToOutputDirectory)'=='PreserveNewest'"/>
727                 </CreateItem>
728
729         </Target>
730
731         <!-- Pre/Post BuildEvents -->
732         <PropertyGroup>
733                 <PreBuildEventDependsOn />
734         </PropertyGroup>
735
736         <Target Name="PreBuildEvent"
737                 Condition="'$(PreBuildEvent)' != ''"
738                 DependsOnTargets="$(PreBuildEventDependsOn)">
739
740                 <Exec WorkingDirectory="$(OutDir)" Command="$(PreBuildEvent)" />
741         </Target>
742
743         <!-- PostBuildEvent depends on $(RunPostBuildEvent)
744
745                 Default: OnBuildSuccess
746                 OnBuildSuccess: Run after a successful build
747                 OnOutputUpdated: Run only if the output assembly got updates
748                 Always: Run always
749         -->
750         <PropertyGroup>
751                 <PostBuildEventDependsOn />
752         </PropertyGroup>
753
754         <!-- this gets invoked in two cases, from CoreBuildDependsOn, if the build completes
755              successfully, OR from OnError in CoreBuild, if the build failed and $(RunPostBuildEvent)
756              is 'Always' or 'OnOutputUpdated'. Invoke $(PostBuildEvent) if its either Empty (== OnBuildSuccess)
757              or OnBuildSuccess or Always OR (OnOutputUpdated and output assembly got updated) -->
758         <Target Name="PostBuildEvent"
759                 Condition="'$(PostBuildEvent)' != '' and
760                         ('$(RunPostBuildEvent)' != 'OnOutputUpdated' or
761                           '$(_AssemblyModifiedTimeBeforeCompile)' != '$(_AssemblyModifiedTimeAfterCompile)')"
762                 DependsOnTargets="$(PostBuildEventDependsOn)">
763
764                 <Exec WorkingDirectory="$(OutDir)" Command="$(PostBuildEvent)" />
765         </Target>
766
767         <!-- Timestamp the output assemblies, required for PostBuildEvent -->
768         <Target Name="_TimestampBeforeCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
769                 <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
770                         <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeBeforeCompile" />
771                 </CreateItem>
772         </Target>
773         <Target Name="_TimestampAfterCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'">
774                 <CreateItem Include="%(IntermediateAssembly.ModifiedTime)">
775                         <Output TaskParameter="Include" PropertyName="_AssemblyModifiedTimeAfterCompile" />
776                 </CreateItem>
777         </Target>
778
779         <!-- Rebuild -->
780         <PropertyGroup>
781                 <RebuildDependsOn>
782                         BeforeRebuild;
783                         Clean;
784                         $(MSBuildProjectDefaultTargets);
785                         AfterRebuild;
786                 </RebuildDependsOn>
787
788                 <RebuildDependsOn Condition="'$(MSBuildProjectDefaultTargets)' == 'Rebuild'">
789                         BeforeRebuild;
790                         Clean;
791                         Build;
792                         AfterRebuild;
793                 </RebuildDependsOn>
794         </PropertyGroup>
795
796         <Target Name="BeforeRebuild" />
797         <Target Name="AfterRebuild" />
798
799         <Target Name="Rebuild"
800                 DependsOnTargets="$(RebuildDependsOn)"
801                 Outputs="$(TargetPath)"/>
802
803         <!-- Clean -->
804         <Target Name="_RecordCleanFile"
805                 DependsOnTargets="_GetCompileOutputsForClean">
806
807                 <!-- add to list of previous writes for this platform/config -->
808
809                 <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
810                         <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
811                 </ReadLinesFromFile>
812
813                 <!-- CopyLocal files: In case all the projects build to common output
814                      directory, then other projects might depend on some of these
815                      CopyLocal files, so delete only the ones under *this* project
816                      directory -->
817                 <FindUnderPath Path="$(MSBuildProjectDirectory)" Files="@(FileWritesShareable)">
818                         <Output TaskParameter="InPath" ItemName="FileWrites"/>
819                 </FindUnderPath>
820
821                 <RemoveDuplicates Inputs="@(PreviousFileWrites);@(FileWrites->'%(FullPath)')">
822                         <Output TaskParameter="Filtered" ItemName="CombinedFileWrites"/>
823                 </RemoveDuplicates>
824
825                 <WriteLinesToFile
826                         File="$(IntermediateOutputPath)$(CleanFile)"
827                         Lines="@(CombinedFileWrites)"
828                         Overwrite="true"/>
829         </Target>
830
831         <PropertyGroup>
832                 <CleanDependsOn>
833                         BeforeClean;
834                         CleanReferencedProjects;
835                         CoreClean;
836                         AfterClean
837                 </CleanDependsOn>
838         </PropertyGroup>
839
840         <Target Name="_GetCompileOutputsForClean">
841                 <!-- assembly and debug file in the *intermediate output path* -->
842                 <CreateItem Include="@(IntermediateAssembly)" Condition="Exists('@(IntermediateAssembly)')">
843                         <Output TaskParameter="Include" ItemName="FileWrites"/>
844                 </CreateItem>
845
846                 <CreateItem Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb"
847                         Condition="Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')">
848                         <Output TaskParameter="Include" ItemName="FileWrites"/>
849                 </CreateItem>
850         </Target>
851
852         <!-- Get the list of files written, for clean -->
853         <Target Name="_GetCleanFileWrites"
854                 DependsOnTargets="_GetCompileOutputsForClean">
855                 <ReadLinesFromFile File="$(IntermediateOutputPath)$(CleanFile)">
856                         <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
857                 </ReadLinesFromFile>
858         </Target>
859
860         <Target Name="CleanReferencedProjects"
861                 DependsOnTargets="AssignProjectConfiguration">
862
863                 <!-- If building from .sln.proj or from IDE, clean will get handled by them,
864                      else we are building a project directly, from the command line, so
865                      clean the referenced projects -->
866                 <MSBuild Projects="@(ProjectReferenceWithConfigurationExistent)"
867                         Targets="Clean"
868                         Condition=" '$(BuildingSolutionFile)' != 'true' and '$(BuildingInsideVisualStudio)' != 'true' and '@(ProjectReferenceWithConfigurationExistent)' != ''" />
869
870         </Target>
871
872         <Target Name="Clean" DependsOnTargets="$(CleanDependsOn)"/>
873
874         <!-- Override in project to run before/after clean tasks -->
875         <Target Name="BeforeClean" />
876         <Target Name="AfterClean" />
877
878         <Target Name="CoreClean" DependsOnTargets="_GetCleanFileWrites">
879                 <Delete Files="@(PreviousFileWrites);@(FileWrites)" TreatErrorsAsWarnings="true"/>
880
881                 <!-- all previous files written for this platform/config have been deleted,
882                      we can safely remove the file list now -->
883                 <Delete Files="$(IntermediateOutputPath)$(CleanFile)" TreatErrorsAsWarnings="true" />
884         </Target>
885
886         <PropertyGroup>
887                 <ImplicitlyExpandDesignTimeFacades>true</ImplicitlyExpandDesignTimeFacades>
888
889                 <ResolveReferencesDependsOn>
890                         $(ResolveReferencesDependsOn);
891                         ImplicitlyExpandDesignTimeFacades
892                 </ResolveReferencesDependsOn>
893
894                 <ImplicitlyExpandDesignTimeFacadesDependsOn>
895                         $(ImplicitlyExpandDesignTimeFacadesDependsOn);
896                         GetReferenceAssemblyPaths
897                 </ImplicitlyExpandDesignTimeFacadesDependsOn>
898         </PropertyGroup>
899
900         <Target Name="ImplicitlyExpandDesignTimeFacades" Condition="'$(ImplicitlyExpandDesignTimeFacades)' == 'true'" DependsOnTargets="$(ImplicitlyExpandDesignTimeFacadesDependsOn)">
901
902                 <PropertyGroup>
903                         <!-- Does one of our dependencies reference a System.Runtime-based portable library? -->
904                         <_HasReferenceToSystemRuntime Condition="'$(DependsOnSystemRuntime)' == 'true' or '%(_ResolvedProjectReferencePaths.TargetPlatformIdentifier)' == 'Portable'">true</_HasReferenceToSystemRuntime>
905                 </PropertyGroup>
906
907                 <ItemGroup Condition="'$(_HasReferenceToSystemRuntime)' == 'true'">
908                         <!-- If the user has manually referenced these assemblies, remove them so we don't end up with duplicates -->
909                         <ReferencePath Remove="@(_DesignTimeFacadeAssemblies)"/>
910                         <ReferencePath Include="%(_DesignTimeFacadeAssemblies.Identity)">
911                                 <WinMDFile>false</WinMDFile>
912                                 <CopyLocal>false</CopyLocal>
913                                 <ResolvedFrom>ImplicitlyExpandDesignTimeFacades</ResolvedFrom>
914                         </ReferencePath>
915                         <_ResolveAssemblyReferenceResolvedFiles Include="@(ReferencePath)" Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandDesignTimeFacades'" />
916                 </ItemGroup>
917
918                 <Message Importance="Low" Text="Including @(ReferencePath)" Condition="'%(ReferencePath.ResolvedFrom)' == 'ImplicitlyExpandDesignTimeFacades'" />
919
920         </Target>
921
922         <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter\*"
923                 Condition="'$(ImportByWildcardAfterMicrosoftCommonTargets)' == 'true' and Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\$(MSBuildThisFile)\ImportAfter')"/>
924 </Project>