Merge pull request #649 from DavidS/feature/implement-additional-reference-path
[mono.git] / mcs / tools / xbuild / xbuild / 2.0 / Microsoft.Common.targets
index 008c27d12f665f1a5b0a7944e8834b1d872ed309..6fec8df52c674c9d7cb091c23996f2c4d7939bd8 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>
                <CleanFile Condition="'$(CleanFile)'==''">$(MSBuildProjectFile).FilesWrittenAbsolute.txt</CleanFile>
        </PropertyGroup>
 
                <IntermediateOutputPath Condition=" '$(PlatformName)' != 'AnyCPU'">$(BaseIntermediateOutputPath)$(PlatformName)\$(Configuration)\</IntermediateOutputPath>
        </PropertyGroup>
 
+       <PropertyGroup>
+               <IntermediateOutputPath Condition="'$(IntermediateOutputPath)' != '' and !HasTrailingSlash('$(IntermediateOutputPath)')">$(IntermediateOutputPath)\</IntermediateOutputPath>
+       </PropertyGroup>
+
        <ItemGroup>
                <IntermediateAssembly Include="$(IntermediateOutputPath)$(AssemblyName)$(TargetExt)" />
 
@@ -52,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>
 
                <AssemblySearchPaths Condition="'$(AssemblySearchPaths)' == ''">
                        {CandidateAssemblyFiles};
                        $(ReferencePath);
+                       @(AdditionalReferencePath);
                        {HintPathFromItem};
                        {TargetFrameworkDirectory};
                        {PkgConfig};
                        ResolveAssemblyReferences;
                        AfterResolveReferences
                </ResolveReferencesDependsOn>
+
+               <ResolveAssemblyReferencesDependsOn>
+                       GetFrameworkPaths;
+                       PrepareForBuild
+               </ResolveAssemblyReferencesDependsOn>
        </PropertyGroup>
 
        <Target Name="ResolveReferences" DependsOnTargets="$(ResolveReferencesDependsOn)"/>
        <Target Name="BeforeResolveReferences" />
        <Target Name="AfterResolveReferences" />
 
-       <Target Name="ResolveAssemblyReferences">
+       <Target Name="ResolveAssemblyReferences" DependsOnTargets="$(ResolveAssemblyReferencesDependsOn)">
                <ResolveAssemblyReference
                        Assemblies="@(Reference)"
                        AssemblyFiles="@(ChildProjectReferences)"
                <Copy
                        SourceFiles="@(ReferenceCopyLocalPaths)"
                        DestinationFiles="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"
-                       SkipUnchangedFiles="true">
-                       <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
+                       SkipUnchangedFiles="$(SkipCopyUnchangedFiles)">
+                       <Output TaskParameter = "DestinationFiles" ItemName = "FileWritesShareable"/>
                </Copy>
        </Target>
 
                <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>
 
+               <!-- 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
+                    directory -->
+               <FindUnderPath Path="$(MSBuildProjectDirectory)" Files="@(FileWritesShareable)">
+                       <Output TaskParameter="InPath" ItemName="FileWrites"/>
+               </FindUnderPath>
+
                <RemoveDuplicates Inputs="@(PreviousFileWrites);@(FileWrites->'%(FullPath)')">
                        <Output TaskParameter="Filtered" ItemName="CombinedFileWrites"/>
                </RemoveDuplicates>