Merge pull request #4829 from JohnChen0/master
[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     <ItemGroup>
18      <DnuSourceList Include="$(CORE_ROOT)\.nuget\pkg" />
19     </ItemGroup>
20
21     <!-- Restore the runtime dependencies -->
22     <Exec Command="$(DnuRestoreCommand) &quot;$(TestRuntimeProjectJson)&quot;"
23            StandardOutputImportance="Low"
24            CustomErrorRegularExpression="^Unable to resolve .*"
25            IgnoreExitCode="true"
26            IgnoreStandardErrorWarningFormat="true" />
27
28     <!-- For each perf test, generate assembly list, and zip up the workitem -->
29     <MSBuild Projects="$(MSBuildProjectFile)" Properties="CurrPerfAssembly=%(CoreCLRPerfTest.Identity);TestRuntimeProjectLockJson=$(TestRuntimeProjectLockJson)" Targets="_zipSingleProject"/>
30
31     <!-- After all workitems are packaged, call the CloudBuild Targets from Build Tools which upload these workitems and trigger a test run for these workitems -->
32     <MSBuild Projects="$(MSBuildProjectFile)" Properties="BinDir=$(BinDir)../" Targets="CloudBuild" />
33
34   </Target>
35
36   <Target Name="_zipSingleProject">
37     <PropertyGroup>
38       <OutDir>$([System.IO.Path]::GetDirectoryName($(CurrPerfAssembly)))/</OutDir>
39       <TestArchiveDir>$(BaseOutputPath)\testStagingDir\</TestArchiveDir>
40       <TestProjectName>$([System.IO.Path]::GetFileNameWithoutExtension($(CurrPerfAssembly)))</TestProjectName>
41       <ProjectLockJson>$(OutDir)project.lock.json</ProjectLockJson>
42     </PropertyGroup>
43
44     <ItemGroup>
45       <TestNugetProjectLockFile Include="$(ProjectLockJson)" Condition="Exists($(ProjectLockJson))"/>
46       <TestNugetProjectLockFile Include="$(TestRuntimeProjectLockJson)" Condition="Exists($(TestRuntimeProjectLockJson))"/>
47     </ItemGroup>
48
49     <!-- Generate Assembly list based on the individual project's project.json as well as the common runtime dependencies generated by AddAssFilesToAssemblyList target -->
50     <PrereleaseResolveNuGetPackageAssets
51                                AllowFallbackOnTargetSelection="true"
52                                IncludeFrameworkReferences="false"
53                                NuGetPackagesDirectory="$(PackagesDir)"
54                                RuntimeIdentifier="$(TestNugetRuntimeId)"
55                                ProjectLanguage="C#"
56                                ProjectLockFile="%(TestNugetProjectLockFile.FullPath)"
57                                TargetMonikers="@(TestTargetFramework)">
58       <Output TaskParameter="ResolvedCopyLocalItems" ItemName="RequiredAssemblies" />
59     </PrereleaseResolveNuGetPackageAssets>
60     <ItemGroup>
61       <AssemblyPaths Include="$([MSBuild]::MakeRelative($(PackagesDir), %(RequiredAssemblies.FullPath)))" />
62     </ItemGroup>
63     <RemoveDuplicatesWithLastOneWinsPolicy Inputs="@(AssemblyPaths)">
64       <Output TaskParameter="Filtered" ItemName="UniqueAssemblyPaths" />
65     </RemoveDuplicatesWithLastOneWinsPolicy>
66     <PropertyGroup>
67       <_TestCopyLocalByFileNameWithoutDuplicates></_TestCopyLocalByFileNameWithoutDuplicates>
68     </PropertyGroup>
69     <ItemGroup>
70       <UniqueAssemblyPaths Include="$([System.String]::Copy('%(_TestCopyLocalByFileNameWithoutDuplicates.SourcePath)').Replace('$(PackagesDir)',''))" Condition="'%(_TestCopyLocalByFileNameWithoutDuplicates.NugetPackageId)' != ''" />
71     </ItemGroup>
72     <WriteLinesToFile
73       File="$(OutDir)/assemblylist.flat.txt"
74       Lines="@(UniqueAssemblyPaths)"
75       Overwrite="true"
76       Encoding="Ascii" />
77
78     <GenerateAssemblyList
79       InputListLocation="$(OutDir)assemblylist.flat.txt"
80       OutputListLocation="$(OutDir)assemblylist.txt"
81      />
82
83     <Message Text="Archiving Perf test assemblies for project: $(OutDir)" Importance="High" />
84     <MSBuild Projects="$(MSBuildProjectFile)" Properties="OutDir=$(OutDir);TestArchiveDir=$(TestArchiveDir);TestProjectName=$(TestProjectName);DisableCopyTestToTestDirectory=true" Targets="ArchiveTestBuild"/>
85   </Target>
86 </Project>