Merge pull request #664 from symform/xbuild-AssignProjectConfiguration
[mono.git] / mcs / tools / xbuild / xbuild / 3.5 / Microsoft.Common.targets
index 8a019c5a61cee08c6ba1f6d05230b33a7ea52198..6a2c6efe85dced063d88c5c0d0a5f862d9cee795 100644 (file)
                <PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
        </PropertyGroup>
 
+       <PropertyGroup>
+               <SkipCopyUnchangedFiles Condition="'$(SkipCopyUnchangedFiles)' == ''">true</SkipCopyUnchangedFiles>
+       </PropertyGroup>
+
        <PropertyGroup>
                <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' == ''">obj\</BaseIntermediateOutputPath>
                <BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)' != '' and !HasTrailingSlash('$(BaseIntermediateOutputPath)')">$(BaseIntermediateOutputPath)\</BaseIntermediateOutputPath>
@@ -57,7 +61,8 @@
        <PropertyGroup>
                <TargetName Condition="'$(TargetName)' == '' ">$(AssemblyName)</TargetName>
                <TargetFileName Condition="'$(TargetFileName)' == '' ">$(TargetName)$(TargetExt)</TargetFileName>
-               <TargetPath>@(_OutDirItem->'%(FullPath)\$(TargetFileName)')</TargetPath>
+               <TargetDir Condition=" '$(TargetDir)' == '' ">@(_OutDirItem->'%(FullPath)')</TargetDir>
+               <TargetPath Condition=" '$(TargetPath)' == '' ">@(_OutDirItem->'%(FullPath)\$(TargetFileName)')</TargetPath>
                <MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildProjectFullPath);$(MSBuildToolsPath)\Microsoft.Common.targets</MSBuildAllProjects>
 
                <KeyOriginatorFile Condition=" '$(SignAssembly)' == 'true' ">$(AssemblyOriginatorKeyFile)</KeyOriginatorFile>
                />
        </Target>
 
-       <Target Name="GetFrameworkPaths">
+       <PropertyGroup>
+               <GetFrameworkPathsDependsOn />
+       </PropertyGroup>
+       <Target Name="GetFrameworkPaths" DependsOnTargets="$(GetFrameworkPathsDependsOn)">
                <GetFrameworkPath>
                        <Output Condition="'$(TargetFrameworkVersion)' == 'v3.5'"
                                TaskParameter="FrameworkVersion35Path"
-                               ItemName="_TargetFrameworkDirectories"/>
+                               ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
                        <Output Condition="'$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'" 
                                TaskParameter="FrameworkVersion30Path"
-                               ItemName="_TargetFrameworkDirectories"/>
+                               ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
                        <Output Condition="'$(TargetFrameworkVersion)' == 'v2.0' or '$(TargetFrameworkVersion)' == 'v3.0' or '$(TargetFrameworkVersion)' == 'v3.5'" 
                                TaskParameter="FrameworkVersion20Path"
-                               ItemName="_TargetFrameworkDirectories"/>
+                               ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
                </GetFrameworkPath>
-               <CreateProperty Value="@(_TargetFrameworkDirectories)">
+               <CreateProperty Value="@(_CombinedTargetFrameworkDirectoriesItem)">
                        <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
                </CreateProperty>
 
                        Condition="'$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v2.0'"/>
        </Target>
 
+       <PropertyGroup>
+               <GetReferenceAssemblyPathsDependsOn />
+       </PropertyGroup>
+       <!-- Multi-targeting against "framework packs" is not supported with ToolsVersion < 4.0,
+            this target is just a place holder, can be overridden -->
+       <Target Name="GetReferenceAssemblyPaths" DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn)" />
+
        <PropertyGroup>
                <AllowedReferenceAssemblyFileExtensions Condition=" '$(AllowedReferenceAssemblyFileExtensions)' == '' ">
                        .exe;
                <AssemblySearchPaths Condition="'$(AssemblySearchPaths)' == ''">
                        {CandidateAssemblyFiles};
                        $(ReferencePath);
+                       @(AdditionalReferencePath);
                        {HintPathFromItem};
                        {TargetFrameworkDirectory};
                        {PkgConfig};
 
                <ResolveAssemblyReferencesDependsOn>
                        GetFrameworkPaths;
+                       GetReferenceAssemblyPaths;
                        PrepareForBuild
                </ResolveAssemblyReferencesDependsOn>
        </PropertyGroup>
                        FindDependencies="true"
                        FindSatellites="true"
                        FindRelatedFiles="true"
+                       TargetFrameworkVersion="$(TargetFrameworkVersion)"
                >
                        <Output TaskParameter="ResolvedFiles" ItemName="ResolvedFiles"/>
                        <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
        </Target>
 
        <Target
-               Name="AssignProjectConfigurations"
+               Name="AssignProjectConfiguration"
                Condition="'@(ProjectReference)' != ''">
 
                <!-- assign configs if building a solution file -->
                ProjectReferenceWithConfigurationNonExistent: Projects non-existent on disk -->
 
        <Target Name="SplitProjectReferencesByExistent"
-               DependsOnTargets="AssignProjectConfigurations">
+               DependsOnTargets="AssignProjectConfiguration">
 
                <CreateItem Include="@(ProjectReferenceWithConfiguration)" Condition="'@(ProjectReferenceWithConfiguration)' != ''">
                        <Output TaskParameter="Include" ItemName="ProjectReferenceWithConfigurationExistent"
                <Copy
                        SourceFiles="@(ReferenceCopyLocalPaths)"
                        DestinationFiles="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"
-                       SkipUnchangedFiles="true">
+                       SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
                        <Output TaskParameter = "DestinationFiles" ItemName = "FileWritesShareable"/>
                </Copy>
        </Target>
 
-<!--
-       Not needed at the moment
        <Target Name="_ComputeNonExistentFileProperty" Condition='false'>
                <CreateProperty Value="__NonExistentSubDir__\__NonExistentFile__">
                        <Output TaskParameter="Value" PropertyName="NonExistentFile"/>
                </CreateProperty>
        </Target>
--->
 
        <PropertyGroup>
                <BuildDependsOn>
                <CoreBuildDependsOn>
                        PrepareForBuild;
                        GetFrameworkPaths;
+                       GetReferenceAssemblyPaths;
                        PreBuildEvent;
                        ResolveReferences;
                        CopyFilesMarkedCopyLocal;
                <MakeDir Directories="$(IntermediateOutputPath)%(ManifestNonResxWithCulture.Culture)"/>
                <Copy SourceFiles = "@(NonResxWithCulture)"
                        DestinationFiles = "@(ManifestNonResxWithCulture->'$(IntermediateOutputPath)%(Identity)')"
-                       SkipUnchangedFiles="true">
+                       SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
                        <Output TaskParameter = "DestinationFiles" ItemName = "ManifestNonResxWithCultureOnDisk"/>
                        <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
                </Copy>
 
                <Copy SourceFiles = "@(NonResxWithNoCulture)"
                        DestinationFiles = "@(ManifestNonResxWithNoCulture->'$(IntermediateOutputPath)%(Identity)')"
-                       SkipUnchangedFiles="true">
+                       SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
                        <Output TaskParameter = "DestinationFiles" ItemName = "ManifestNonResxWithNoCultureOnDisk"/>
                        <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
                </Copy>
                        SourceFiles="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb"
                        Condition="'$(OutDir)' != '' and Exists('$(IntermediateOutputPath)$(AssemblyName)$(TargetExt).mdb')"
                        DestinationFolder="$(OutDir)"
-                       SkipUnchangedFiles="true" >
+                       SkipUnchangedFiles="$(SkipCopyUnchangedFiles)" >
                        <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
                </Copy>
 
-               <Copy SourceFiles="@(IntermediateAssembly)" Condition="'$(OutDir)' != '' and Exists ('@(IntermediateAssembly)')" DestinationFolder="$(OutDir)" SkipUnchangedFiles="true">
+               <Copy SourceFiles="@(IntermediateAssembly)" Condition="'$(OutDir)' != '' and Exists ('@(IntermediateAssembly)')" DestinationFolder="$(OutDir)" SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
                        <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
                </Copy>
 
                        SourceFiles = "@(IntermediateSatelliteAssemblies)"
                        DestinationFiles = "@(IntermediateSatelliteAssemblies->'$(OutDir)\%(Culture)\$(AssemblyName).resources.dll')"
                        Condition = "'@(IntermediateSatelliteAssemblies)' != ''"
-                       SkipUnchangedFiles="true">
+                       SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
                        <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
                </Copy>
        </Target>
                Outputs="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')">
 
                <Copy SourceFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest)"
-                       DestinationFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')">
+                       DestinationFiles="@(ItemsToCopyToOutputDirectoryPreserveNewest->'$(OutDir)%(TargetPath)')"
+                       SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
                        <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
                </Copy>
        </Target>
                        <Output TaskParameter="Lines" ItemName="PreviousFileWrites"/>
                </ReadLinesFromFile>
 
-               <RemoveDuplicates Inputs="@(PreviousFileWrites);@(FileWrites->'%(FullPath)')">
-                       <Output TaskParameter="Filtered" ItemName="CombinedFileWrites"/>
-               </RemoveDuplicates>
-
                <!-- CopyLocal files: In case all the projects build to common output
                     directory, then other projects might depend on some of these
                     CopyLocal files, so delete only the ones under *this* project
                        <Output TaskParameter="InPath" ItemName="FileWrites"/>
                </FindUnderPath>
 
+               <RemoveDuplicates Inputs="@(PreviousFileWrites);@(FileWrites->'%(FullPath)')">
+                       <Output TaskParameter="Filtered" ItemName="CombinedFileWrites"/>
+               </RemoveDuplicates>
+
                <WriteLinesToFile
                        File="$(IntermediateOutputPath)$(CleanFile)"
                        Lines="@(CombinedFileWrites)"
        </Target>
 
        <Target Name="CleanReferencedProjects"
-               DependsOnTargets="AssignProjectConfigurations">
+               DependsOnTargets="AssignProjectConfiguration">
 
                <!-- If building from .sln.proj or from IDE, clean will get handled by them,
                     else we are building a project directly, from the command line, so