[xbuild] ResolveAssemblyReference - add missing api.
[mono.git] / mcs / tools / xbuild / xbuild / 3.5 / Microsoft.Common.targets
index 44e8b01d9e3235f14a6d20d7eba6137864edfa31..2efac100f43ebeb6f10c49fafd29896c39aad36b 100644 (file)
@@ -34,6 +34,7 @@
 
        <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 +57,9 @@
        <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>
        </PropertyGroup>
                />
        </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="@(_CombinedTargetFrameworkDirectoriesItem)">
+                       <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
+               </CreateProperty>
+
                <Warning Text="TargetFrameworkVersion '$(TargetFrameworkVersion)' not supported by this toolset (ToolsVersion: $(MSBuildToolsVersion))."
                        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);
                        {HintPathFromItem};
                        {TargetFrameworkDirectory};
                        {PkgConfig};
                        ResolveAssemblyReferences;
                        AfterResolveReferences
                </ResolveReferencesDependsOn>
+
+               <ResolveAssemblyReferencesDependsOn>
+                       GetFrameworkPaths;
+                       GetReferenceAssemblyPaths;
+                       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)"
                        SearchPaths="$(AssemblySearchPaths)"
                        CandidateAssemblyFiles="@(Content);@(None)"
-                       TargetFrameworkDirectories="@(TargetFrameworkDirectories)"
+                       TargetFrameworkDirectories="$(TargetFrameworkDirectory)"
                        AllowedAssemblyExtensions="$(AllowedReferenceAssemblyFileExtensions)"
                        AllowedRelatedFileExtensions="$(AllowedReferenceRelatedFileExtensions)"
                        FindDependencies="true"
                        FindSatellites="true"
                        FindRelatedFiles="true"
+                       TargetFrameworkVersion="$(TargetFrameworkVersion)"
                >
                        <Output TaskParameter="ResolvedFiles" ItemName="ResolvedFiles"/>
                        <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
                        SourceFiles="@(ReferenceCopyLocalPaths)"
                        DestinationFiles="@(ReferenceCopyLocalPaths->'$(OutDir)%(DestinationSubDirectory)%(Filename)%(Extension)')"
                        SkipUnchangedFiles="true">
-                       <Output TaskParameter = "DestinationFiles" ItemName = "FileWrites"/>
+                       <Output TaskParameter = "DestinationFiles" ItemName = "FileWritesShareable"/>
                </Copy>
        </Target>
 
                <CoreBuildDependsOn>
                        PrepareForBuild;
                        GetFrameworkPaths;
+                       GetReferenceAssemblyPaths;
                        PreBuildEvent;
                        ResolveReferences;
                        CopyFilesMarkedCopyLocal;
                        <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
+                    directory -->
+               <FindUnderPath Path="$(MSBuildProjectDirectory)" Files="@(FileWritesShareable)">
+                       <Output TaskParameter="InPath" ItemName="FileWrites"/>
+               </FindUnderPath>
+
                <WriteLinesToFile
                        File="$(IntermediateOutputPath)$(CleanFile)"
                        Lines="@(CombinedFileWrites)"