Merge pull request #3915 from hughbe/region-info-params
[platform/upstream/coreclr.git] / tests / helixperftasks.targets
1 <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2   <UsingTask TaskName="GetPerfTestAssemblies" AssemblyFile="$(ToolsDir)net45/Microsoft.DotNet.Build.CloudTestTasks.dll"/>
3   <Import Project="$(ToolsDir)publishtest.targets" />
4   <Import Project="$(ToolsDir)CloudTest.targets" />
5   <Target Name="UploadPerfAssemblies">
6     <Message Text="Searching for Perf tests in $(BinDir)" Importance = "High"/>
7     <ItemGroup>
8       <TestBinary Include="$(BinDir)**/*.dll" />
9       <TestBinary Include="$(BinDir)**/*.exe" />
10     </ItemGroup>
11
12     <!-- Get full paths to each of the perf test directories -->
13     <GetPerfTestAssemblies TestBinaries="@(TestBinary)" GetFullPaths="true">
14       <Output TaskParameter="PerfTestAssemblies" ItemName="CoreCLRPerfTest" />
15     </GetPerfTestAssemblies>
16
17     <PropertyGroup>
18       <TestRuntimeDependenciesJson>$(SourceDir)Common\test_runtime\project.json</TestRuntimeDependenciesJson>
19       <TestRuntimeProjectLockJson>$(SourceDir)Common\test_runtime\project.lock.json</TestRuntimeProjectLockJson>
20     </PropertyGroup>
21
22     <!-- Restore the runtime dependencies -->
23     <Exec Command="$(DnuRestoreCommand) &quot;$(TestRuntimeDependenciesJson)&quot;"
24            StandardOutputImportance="Low"
25            CustomErrorRegularExpression="^Unable to resolve .*"
26            IgnoreExitCode="true"
27            IgnoreStandardErrorWarningFormat="true" />
28
29     <!-- For each perf test, generate assembly list, and zip up the workitem -->
30     <MSBuild Projects="$(MSBuildProjectFile)" Properties="CurrPerfAssembly=%(CoreCLRPerfTest.Identity);TestRuntimeProjectLockJson=$(TestRuntimeProjectLockJson)" Targets="_zipSingleProject"/>
31
32     <!-- After all workitems are packaged, call the CloudBuild Targets from Build Tools which upload these workitems and trigger a test run for these workitems -->
33     <MSBuild Projects="$(MSBuildProjectFile)" Properties="BinDir=$(BinDir)../" Targets="CloudBuild" />
34
35   </Target>
36
37   <Target Name="_zipSingleProject">
38     <PropertyGroup>
39       <OutDir>$([System.IO.Path]::GetDirectoryName($(CurrPerfAssembly)))/</OutDir>
40       <TestArchiveDir>$(BaseOutputPath)\testStagingDir\</TestArchiveDir>
41       <TestProjectName>$([System.IO.Path]::GetFileNameWithoutExtension($(CurrPerfAssembly)))</TestProjectName>
42       <ProjectLockJson>$(OutDir)project.lock.json</ProjectLockJson>
43     </PropertyGroup>
44
45     <ItemGroup>
46       <TestNugetProjectLockFile Include="$(ProjectLockJson)" Condition="Exists($(ProjectLockJson))"/>
47       <TestNugetProjectLockFile Include="$(TestRuntimeProjectLockJson)" Condition="Exists($(TestRuntimeProjectLockJson))"/>
48     </ItemGroup>
49
50     <!-- Generate Assembly list based on the individual project's project.json as well as the common runtime dependencies generated by AddAssFilesToAssemblyList target -->
51     <PrereleaseResolveNuGetPackageAssets
52                                AllowFallbackOnTargetSelection="true"
53                                IncludeFrameworkReferences="false"
54                                NuGetPackagesDirectory="$(PackagesDir)"
55                                RuntimeIdentifier="$(TestNugetRuntimeId)"
56                                ProjectLanguage="C#"
57                                ProjectLockFile="%(TestNugetProjectLockFile.FullPath)"
58                                TargetMonikers="@(TestTargetFramework)">
59       <Output TaskParameter="ResolvedCopyLocalItems" ItemName="RequiredAssemblies" />
60     </PrereleaseResolveNuGetPackageAssets>
61     <ItemGroup>
62       <AssemblyPaths Include="$([MSBuild]::MakeRelative($(PackagesDir), %(RequiredAssemblies.FullPath)))" />
63     </ItemGroup>
64     <RemoveDuplicatesWithLastOneWinsPolicy Inputs="@(AssemblyPaths)">
65       <Output TaskParameter="Filtered" ItemName="UniqueAssemblyPaths" />
66     </RemoveDuplicatesWithLastOneWinsPolicy>
67     <PropertyGroup>
68       <_TestCopyLocalByFileNameWithoutDuplicates></_TestCopyLocalByFileNameWithoutDuplicates>
69     </PropertyGroup>
70     <ItemGroup>
71       <UniqueAssemblyPaths Include="$([System.String]::Copy('%(_TestCopyLocalByFileNameWithoutDuplicates.SourcePath)').Replace('$(PackagesDir)',''))" Condition="'%(_TestCopyLocalByFileNameWithoutDuplicates.NugetPackageId)' != ''" />
72     </ItemGroup>
73     <WriteLinesToFile
74       File="$(OutDir)/assemblylist.flat.txt"
75       Lines="@(UniqueAssemblyPaths)"
76       Overwrite="true"
77       Encoding="Ascii" />
78
79     <GenerateAssemblyList
80       InputListLocation="$(OutDir)assemblylist.flat.txt"
81       OutputListLocation="$(OutDir)assemblylist.txt"
82      />
83
84     <Message Text="Archiving Perf test assemblies for project: $(OutDir)" Importance="High" />
85     <MSBuild Projects="$(MSBuildProjectFile)" Properties="OutDir=$(OutDir);TestArchiveDir=$(TestArchiveDir);TestProjectName=$(TestProjectName);DisableCopyTestToTestDirectory=true" Targets="ArchiveTestBuild"/>
86   </Target>
87 </Project>