677d3d9db5b706e5905ca33a55dca0fd7d2cfe09
[platform/upstream/coreclr.git] / tests / src / dir.targets
1 <Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
3   <PropertyGroup Condition="'$(TargetFrameworkVersion)' != '' and '$(TargetFrameworkProfile)' != ''">
4     <TargetingPortable>true</TargetingPortable>
5   </PropertyGroup>
6
7   <!-- Setup the default target for projects not already explicitly targeting portable -->
8   <PropertyGroup Condition="'$(TargetingPortable)' != 'true'">
9     <!-- Setting a default portable profile, although nothing should resolve from there as we BuildProjectDir to use the pacakge refs -->
10     <TargetPlatformIdentifier>Portable</TargetPlatformIdentifier>
11     <TargetFrameworkIdentifier>.NETPortable</TargetFrameworkIdentifier>
12     <TargetFrameworkVersion Condition="'$(TargetFrameworkVersion)' == ''">v4.5</TargetFrameworkVersion>
13     <TargetFrameworkProfile Condition="'$(TargetFrameworkProfile)' == ''">Profile7</TargetFrameworkProfile>
14     <TargetFrameworkMonikerDisplayName>.NET Portable Subset</TargetFrameworkMonikerDisplayName>
15     <ImplicitlyExpandTargetFramework Condition="'$(ImplicitlyExpandTargetFramework)' == ''">false</ImplicitlyExpandTargetFramework>
16
17     <AssemblySearchPaths>
18       {HintPathFromItem};
19       $(OutDir);
20       {RawFileName};
21     </AssemblySearchPaths>
22     <!-- For our projects we don't BuildProjectDir to resolve from the usual paths for now only hint paths and output directory 
23       {CandidateAssemblyFiles};
24       $(ReferencePath);
25       {TargetFrameworkDirectory};
26       {Registry:$(FrameworkRegistryBase),$(TargetFrameworkVersion),$(AssemblyFoldersSuffix)$(AssemblyFoldersExConditions)};
27     -->
28   </PropertyGroup>
29
30   <!-- Need to add references to the mscorlib design-time facade for some old-style portable dependencies like xunit -->
31   <Target Name="AddDesignTimeFacadeReferences"
32       Condition="'$(TargetingPortable)' != 'true'"
33       BeforeTargets="ResolveReferences"
34       DependsOnTargets="GetReferenceAssemblyPaths"
35   >
36     <ItemGroup>
37       <PossibleTargetFrameworks Include="$(_TargetFrameworkDirectories)" />
38       <ReferencePath Condition="'$(LinkLocalMscorlib)' != 'true'" Include="%(PossibleTargetFrameworks.Identity)mscorlib.dll" />
39       <ReferencePath Condition="'$(LinkLocalMscorlib)' == 'true'" Include="$(ProjectDir)\..\bin\Product\$(BuildOS).$(BuildArch).$(BuildType)\mscorlib.dll" />
40     </ItemGroup>
41   </Target>
42
43   <!-- Project language -->
44   <PropertyGroup Condition="'$(ProjectLanguage)' == ''">
45     <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.ilproj' OR '$(Language)' == 'IL'">IL</ProjectLanguage>
46     <ProjectLanguage Condition="'$(MSBuildProjectExtension)' == '.csproj' OR '$(Language)' == 'C#' OR '$(ProjectLanguage)'==''">CSharp</ProjectLanguage>
47   </PropertyGroup>
48
49   <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" Condition="'$(ProjectLanguage)' == 'CSharp'" />
50
51   <!-- TODO (#1122): import this from the ToolsDir once it becomes available -->
52   <Import Project="$(ProjectDir)src\IL.targets" Condition="'$(ProjectLanguage)' == 'IL'" />
53
54   <Import Project="$(ToolsDir)packageresolve.targets" Condition="Exists('$(ToolsDir)packageresolve.targets')" />
55
56   <Import Project="$(ToolsDir)sign.targets" Condition="Exists('$(ToolsDir)sign.targets')" />
57
58   <PropertyGroup>
59     <GenerateRunScript Condition="'$(OutputType.ToUpper())' != 'EXE' And '$(GenerateRunScript)' == ''">false</GenerateRunScript>
60   </PropertyGroup>
61
62   <Import Project="CLRTest.Execute.targets" />
63   <Target Name="CreateExecuteScript" 
64           AfterTargets="Build"
65           Condition="'$(GenerateRunScript)' != 'false'"
66           DependsOnTargets="GenerateExecutionScriptsInternal" />
67
68   <PropertyGroup>
69       <OutDir>$(BaseOutputPathWithConfig)$(BuildProjectRelativeDir)\</OutDir>
70   </PropertyGroup>
71
72   <Target Name="CopyNativeProjectBinaries">
73      <ItemGroup>
74         <NativeProjectBinaries Include="$(NativeProjectOutputFolder)\**\*.*" />
75      </ItemGroup>
76
77      <Error  Text="The native project files are missing in $(NativeProjectOutputFolder) please run build from the root of the repo at least once"
78              Condition="'@(NativeProjectBinaries)' == ''" />
79
80      <Copy
81         SourceFiles="@(NativeProjectBinaries)"
82         DestinationFiles="@(NativeProjectBinaries -> '$(OutDir)%(RecursiveDir)%(Filename)%(Extension)')"
83         SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
84         OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
85         Retries="$(CopyRetryCount)"
86         RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
87         UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
88         <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
89      </Copy>
90   </Target>
91
92   <Target Name="ResolveCmakeNativeProjectReference"
93           Condition="'@(ProjectReference)' != ''"
94           BeforeTargets="BeforeResolveReferences;BeforeClean" >
95      <ItemGroup>
96         <NativeProjectReference Include="%(ProjectReference.Identity)" Condition="$([System.String]::Copy(%(ProjectReference.FileName)).ToUpper()) == 'CMAKELISTS'" />
97         <ProjectReference Remove="%(NativeProjectReference.Identity)" />
98         <NativeProjectReferenceNormalized Include="@(NativeProjectReference -> '%(FullPath)')" />
99      </ItemGroup>
100   </Target>
101
102   <Target Name="ConsolidateNativeProjectReference"
103           Condition="'@(ProjectReference)' != ''"
104           BeforeTargets="Build" >
105      <ItemGroup>
106         <NativeProjectOutputFoldersToCopy Include="$([System.String]::Copy('%(NativeProjectReferenceNormalized.RelativeDir)').Replace($(SourceDir),$(__NativeTestIntermediatesDir)\src\))$(Configuration)\"/>
107      </ItemGroup>
108
109     <Message Text= "Project files are :$([System.String]::Copy(%(ProjectReference.FileName)).ToUpper()) " />
110     <Message Text= "Project references are :%(ProjectReference.Identity)" />
111     <Message Text= "Native project references are :%(NativeProjectReference.Identity)" />
112     <Message Text= "Full native project references are :%(NativeProjectReferenceNormalized.Identity)" />
113     <Message Text= "Native binaries will be copied from :%(NativeProjectOutputFoldersToCopy.Identity)" />
114    <MSBuild Projects="$(MSBuildProjectFile)" Targets="CopyNativeProjectBinaries" Properties="NativeProjectOutputFolder=%(NativeProjectOutputFoldersToCopy.Identity)" Condition="'@(NativeProjectReference)' != ''" />
115
116   </Target>
117 </Project>
118