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