[xbuild] ResolveAssemblyReference - add missing api.
[mono.git] / mcs / tools / xbuild / xbuild / 4.0 / Microsoft.Common.targets
index 6545fc826d5f632b36bbdd613c06c33b6cee71c6..f1195b86ee4895be37b5d9276fdaf1373177c2c9 100644 (file)
                <OutputPath Condition="'$(OutputPath)' != '' and !HasTrailingSlash('$(OutputPath)')">$(OutputPath)\</OutputPath> 
                <OutputPath Condition=" '$(Platform)'=='' and '$(Configuration)'=='' and '$(OutputPath)'=='' ">bin\Debug\</OutputPath>
                <WarningLevel Condition="'$(WarningLevel)' == ''" >2</WarningLevel>
-               <TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v2.0</TargetFrameworkVersion>
+
+               <TargetFrameworkIdentifier Condition="'$(TargetFrameworkIdentifier)' == ''">.NETFramework</TargetFrameworkIdentifier>
+               <TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.0</TargetFrameworkVersion>
+
+               <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == '' and '$(TargetFrameworkProfile)' != ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion),Profile=$(TargetFrameworkProfile)</TargetFrameworkMoniker>
+               <TargetFrameworkMoniker Condition="'$(TargetFrameworkMoniker)' == ''">$(TargetFrameworkIdentifier),Version=$(TargetFrameworkVersion)</TargetFrameworkMoniker>
        </PropertyGroup>
 
        <PropertyGroup>
                <_OriginalPlatform>$(Platform)</_OriginalPlatform>
                <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
                <PlatformName Condition="'$(PlatformName)' == ''">$(Platform)</PlatformName>
+
+               <AddAdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == ''">true</AddAdditionalExplicitAssemblyReferences>
+               <AdditionalExplicitAssemblyReferences Condition="'$(AddAdditionalExplicitAssemblyReferences)' == 'true' and '$(TargetFrameworkVersion)' != 'v2.0' and '$(TargetFrameworkVersion)' != 'v3.0'">System.Core;$(AdditionalExplicitAssemblyReferences)</AdditionalExplicitAssemblyReferences>
        </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,9 +65,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"
+               Condition="'$(TargetFrameworkIdentifier)' == '' or '$(TargetFrameworkIdentifier)' == '.NETFramework'"
+               DependsOnTargets="$(GetFrameworkPathsDependsOn)">
                <GetFrameworkPath>
                        <Output Condition="'$(TargetFrameworkVersion)' == 'v4.0'"
                                TaskParameter="FrameworkVersion40Path"
-                               ItemName="_TargetFrameworkDirectories"/>
+                               ItemName="_CombinedTargetFrameworkDirectoriesItem"/>
                        <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)' != 'v4.0' and '$(TargetFrameworkVersion)' != 'v3.5' and '$(TargetFrameworkVersion)' != 'v3.0' and '$(TargetFrameworkVersion)' != 'v2.0'"/>
        </Target>
 
+       <PropertyGroup>
+               <GetReferenceAssemblyPathsDependsOn />
+       </PropertyGroup>
+       <Target Name="GetReferenceAssemblyPaths" DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn)">
+               <!-- in case of .NETFramework, $(TargetFrameworkDirectory) would have been set by
+               GetFrameworkPaths, if it hasn't been changed, then clear it, to avoid duplicates -->
+               <CreateProperty Value="" Condition="'@(_CombinedTargetFrameworkDirectoriesItem)' == '$(TargetFrameworkDirectory)'">
+                       <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
+               </CreateProperty>
+
+               <GetReferenceAssemblyPaths
+                       Condition="'$(TargetFrameworkMoniker)' != ''"
+                       TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
+                       RootPath="$(TargetFrameworkRootPath)">
+
+                       <Output TaskParameter="ReferenceAssemblyPaths" PropertyName="_TargetFrameworkDirectories"/>
+                       <Output TaskParameter="FullFrameworkReferenceAssemblyPaths" PropertyName="_FullFrameworkReferenceAssemblyPaths"/>
+                       <Output TaskParameter="TargetFrameworkMonikerDisplayName" PropertyName="TargetFrameworkMonikerDisplayName"/>
+               </GetReferenceAssemblyPaths>
+
+               <CreateProperty Value="$(_TargetFrameworkDirectories);$(TargetFrameworkDirectory)">
+                       <Output TaskParameter="Value" PropertyName="TargetFrameworkDirectory"/>
+               </CreateProperty>
+       </Target>
+
        <PropertyGroup>
                <AllowedReferenceAssemblyFileExtensions Condition=" '$(AllowedReferenceAssemblyFileExtensions)' == '' ">
                        .exe;
                        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)">
+               <CreateItem Include="@(Reference)" Exclude="$(AdditionalExplicitAssemblyReferences)">
+                       <Output TaskParameter="Include" ItemName="_Reference"/>
+               </CreateItem>
+
+               <CreateItem Include="$(AdditionalExplicitAssemblyReferences)">
+                       <Output TaskParameter="Include" ItemName="_Reference"/>
+               </CreateItem>
+
                <ResolveAssemblyReference
-                       Assemblies="@(Reference)"
+                       Assemblies="@(_Reference)"
                        AssemblyFiles="@(ChildProjectReferences)"
                        SearchPaths="$(AssemblySearchPaths)"
                        CandidateAssemblyFiles="@(Content);@(None)"
                        FindDependencies="true"
                        FindSatellites="true"
                        FindRelatedFiles="true"
+                       TargetFrameworkMoniker="$(TargetFrameworkMoniker)"
+                       TargetFrameworkMonikerDisplayName="$(TargetFrameworkMonikerDisplayName)"
+                       TargetFrameworkVersion="$(TargetFrameworkVersion)"
                >
                        <Output TaskParameter="ResolvedFiles" ItemName="ResolvedFiles"/>
                        <Output TaskParameter="ResolvedFiles" ItemName="ReferencePath"/>
                <CoreBuildDependsOn>
                        PrepareForBuild;
                        GetFrameworkPaths;
+                       GetReferenceAssemblyPaths;
                        PreBuildEvent;
                        ResolveReferences;
                        CopyFilesMarkedCopyLocal;