Clean up 2.0.0 BuildTools PR
[platform/upstream/coreclr.git] / tests / helixperftasks.targets
1 <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
2
3     <UsingTask TaskName="RemoveDuplicateAssemblies" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
4       <ParameterGroup>
5         <DuplicateAssemblies ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
6         <AssemblyPaths ParameterType="Microsoft.Build.Framework.ITaskItem[]" Required="true" />
7         <UniqueAssemblyPaths ParameterType="Microsoft.Build.Framework.ITaskItem[]" Output="true" />
8       </ParameterGroup>
9       <Task>
10         <Using Namespace="System"/>
11         <Using Namespace="System.IO"/>
12         <Using Namespace="System.Collections.Generic"/>
13         <Code Type="Fragment" Language="cs">
14           <![CDATA[
15                   var uniqueAssemblyPathsList = new List<Microsoft.Build.Framework.ITaskItem>();
16                   var dupeSet = new HashSet<string>();
17                   foreach(var dupe in DuplicateAssemblies)
18                   {
19                     dupeSet.Add(dupe.GetMetadata("Identity"));
20                   }
21                   foreach(var assemPath in AssemblyPaths)
22                   {
23                     if((dupeSet.Contains(assemPath.GetMetadata("FileName")+assemPath.GetMetadata("Extension")) &&
24                         !(assemPath.GetMetadata("Identity").StartsWith("runtime"))))
25                     {
26                       Log.LogMessage("Duplicate assembly filtered: {0}", assemPath.GetMetadata("Identity"));
27                     }
28                     else
29                     {
30                       uniqueAssemblyPathsList.Add(assemPath);
31                     }
32
33                   }
34                   UniqueAssemblyPaths = uniqueAssemblyPathsList.ToArray();
35           ]]>
36         </Code>
37       </Task>
38     </UsingTask>
39
40
41   <UsingTask TaskName="GetPerfTestAssemblies" AssemblyFile="$(ToolsDir)net45/Microsoft.DotNet.Build.CloudTestTasks.dll"/>
42   <Import Project="$(ToolsDir)publishtest.targets" />
43   <Import Project="$(ToolsDir)CloudTest.targets" />
44   <Target Name="UploadPerfAssemblies">
45     <Message Text="Searching for Perf tests in $(BinDir)" Importance = "High"/>
46     <ItemGroup>
47       <TestBinary Include="$(BinDir)**/*.dll" />
48       <TestBinary Include="$(BinDir)**/*.exe" />
49     </ItemGroup>
50     <!-- Get full paths to each of the perf test directories -->
51     <GetPerfTestAssemblies TestBinaries="@(TestBinary)" GetFullPaths="true">
52       <Output TaskParameter="PerfTestAssemblies" ItemName="CoreCLRPerfTest" />
53     </GetPerfTestAssemblies>
54
55     <!-- Restore the runtime dependencies -->
56     <Exec Command="$(DotnetRestoreCommand) &quot;$(TestRuntimeProjectJson)&quot;"
57            StandardOutputImportance="Low"
58            CustomErrorRegularExpression="^Unable to resolve .*"
59            IgnoreExitCode="true"
60            IgnoreStandardErrorWarningFormat="true" />
61
62     <!-- For each perf test, generate assembly list, and zip up the workitem -->
63     <MSBuild Projects="$(MSBuildProjectFile)" Properties="CurrPerfAssembly=%(CoreCLRPerfTest.Identity);TestRuntimeProjectLockJson=$(TestRuntimeProjectLockJson)" Targets="_zipSingleProject"/>
64
65     <!-- After all workitems are packaged, call the CloudBuild Targets from Build Tools which upload these workitems and trigger a test run for these workitems -->
66     <MSBuild Projects="$(MSBuildProjectFile)" Properties="BinDir=$(BinDir)../" Targets="CloudBuild" />
67
68   </Target>
69
70   <Target Name="RunTestsForProject">
71     <Message Text="This is a dummy target to appease DependsOnTargets for ArchiveTestBuild in publishtest.targets" Importance="Low" />
72   </Target>
73
74   <!-- CoreCLR builds do not generate dependency lists yet, we need to archive the whole packages dir so that tests can find dependencies -->
75   <!-- compress the required files from the packages dir in preparation for uploading -->
76   <Target Name="CompressPackagesDir">
77     <ItemGroup>
78       <ExcludeFromArchive Include="nupkg$" />
79       <ExcludeFromArchive Include="Microsoft.DotNet.BuildTools" />
80       <ExcludeFromArchive Include="TestData" />
81     </ItemGroup>
82     <ZipFileCreateFromDirectory
83         SourceDirectory="$(PackagesDir)"
84         DestinationArchive="$(PackagesArchiveFile)"
85         ExcludePatterns="@(ExcludeFromArchive)"
86         OverwriteDestination="true" />
87     <ItemGroup>
88       <ForUpload Include="$(PackagesArchiveFile)">
89         <RelativeBlobPath>$(Platform)$(ConfigurationGroup)/$(PackagesArchiveFilename)</RelativeBlobPath>
90       </ForUpload>
91     </ItemGroup>
92   </Target>
93
94   <Target Name="_zipSingleProject">
95     <PropertyGroup>
96       <OutDir>$([System.IO.Path]::GetDirectoryName($(CurrPerfAssembly)))/</OutDir>
97       <TestArchiveDir>$(BaseOutputPath)\testStagingDir\</TestArchiveDir>
98       <TestProjectName>$([System.IO.Path]::GetFileNameWithoutExtension($(CurrPerfAssembly)))</TestProjectName>
99       <ProjectLockJson>$(OutDir)project.lock.json</ProjectLockJson>
100     </PropertyGroup>
101
102     <ItemGroup>
103       <TestNugetProjectLockFile Include="$(ProjectLockJson)" Condition="Exists($(ProjectLockJson))"/>
104       <TestNugetProjectLockFile Include="$(TestRuntimeProjectLockJson)" Condition="Exists($(TestRuntimeProjectLockJson))"/>
105     </ItemGroup>
106
107     <!-- Generate Assembly list based on the individual project's project.json as well as the common runtime dependencies generated by AddAssFilesToAssemblyList target -->
108     <PrereleaseResolveNuGetPackageAssets
109                                AllowFallbackOnTargetSelection="true"
110                                IncludeFrameworkReferences="false"
111                                NuGetPackagesDirectory="$(PackagesDir)"
112                                RuntimeIdentifier="$(TestNugetRuntimeId)"
113                                ProjectLanguage="C#"
114                                ProjectLockFile="%(TestNugetProjectLockFile.FullPath)"
115                                TargetMonikers="@(TestTargetFramework)">
116       <Output TaskParameter="ResolvedCopyLocalItems" ItemName="RequiredAssemblies" />
117     </PrereleaseResolveNuGetPackageAssets>
118
119
120     <ItemGroup>
121       <AssemblyPaths Include="$([MSBuild]::MakeRelative($(PackagesDir), %(RequiredAssemblies.FullPath)))" />
122       <AssemblyFiles Include="@(RequiredAssemblies->'%(FileName)%(Extension)')"></AssemblyFiles>
123       <DupeAssemblies Include="%(AssemblyFiles.Identity)" Condition="'@(AssemblyFiles->Count())' &gt; 1"> </DupeAssemblies>
124     </ItemGroup>
125     <!-- There are duplicate dependency assemblies calculated for some projects that we need to fix, this is check/fix to weed out duplicates -->
126     <RemoveDuplicateAssemblies AssemblyPaths="@(AssemblyPaths)" DuplicateAssemblies="@(DupeAssemblies)">
127       <Output TaskParameter="UniqueAssemblyPaths" ItemName="UniqueAssemblyPaths" />
128     </RemoveDuplicateAssemblies>
129
130     <WriteLinesToFile
131       File="$(OutDir)/assemblylist.flat.txt"
132       Lines="@(UniqueAssemblyPaths)"
133       Overwrite="true"
134       Encoding="Ascii" />
135
136     <GenerateAssemblyList
137       InputListLocation="$(OutDir)assemblylist.flat.txt"
138       OutputListLocation="$(OutDir)assemblylist.txt"
139      />
140
141     <Message Text="Archiving Perf test assemblies for project: $(OutDir)" Importance="High" />
142     <MSBuild Projects="$(MSBuildProjectFile)" Properties="OutDir=$(OutDir);TestArchiveDir=$(TestArchiveDir);TestProjectName=$(TestProjectName)" Targets="ArchiveTestBuild"/>
143   </Target>
144 </Project>