1 <Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3 <UsingTask TaskName="RemoveDuplicateAssemblies" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll" >
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" />
10 <Using Namespace="System"/>
11 <Using Namespace="System.IO"/>
12 <Using Namespace="System.Collections.Generic"/>
13 <Code Type="Fragment" Language="cs">
15 var uniqueAssemblyPathsList = new List<Microsoft.Build.Framework.ITaskItem>();
16 var dupeSet = new HashSet<string>();
17 foreach(var dupe in DuplicateAssemblies)
19 dupeSet.Add(dupe.GetMetadata("Identity"));
21 foreach(var assemPath in AssemblyPaths)
23 if((dupeSet.Contains(assemPath.GetMetadata("FileName")+assemPath.GetMetadata("Extension")) &&
24 !(assemPath.GetMetadata("Identity").StartsWith("runtime"))))
26 Log.LogMessage("Duplicate assembly filtered: {0}", assemPath.GetMetadata("Identity"));
30 uniqueAssemblyPathsList.Add(assemPath);
34 UniqueAssemblyPaths = uniqueAssemblyPathsList.ToArray();
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"/>
47 <TestBinary Include="$(BinDir)**/*.dll" />
48 <TestBinary Include="$(BinDir)**/*.exe" />
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>
55 <!-- Restore the runtime dependencies -->
56 <Exec Command="$(DotnetRestoreCommand) "$(TestRuntimeProjectJson)""
57 StandardOutputImportance="Low"
58 CustomErrorRegularExpression="^Unable to resolve .*"
60 IgnoreStandardErrorWarningFormat="true" />
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"/>
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" />
70 <Target Name="RunTestsForProject">
71 <Message Text="This is a dummy target to appease DependsOnTargets for ArchiveTestBuild in publishtest.targets" Importance="Low" />
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">
78 <ExcludeFromArchive Include="nupkg$" />
79 <ExcludeFromArchive Include="Microsoft.DotNet.BuildTools" />
80 <ExcludeFromArchive Include="TestData" />
82 <ZipFileCreateFromDirectory
83 SourceDirectory="$(PackagesDir)"
84 DestinationArchive="$(PackagesArchiveFile)"
85 ExcludePatterns="@(ExcludeFromArchive)"
86 OverwriteDestination="true" />
88 <ForUpload Include="$(PackagesArchiveFile)">
89 <RelativeBlobPath>$(Platform)$(ConfigurationGroup)/$(PackagesArchiveFilename)</RelativeBlobPath>
94 <Target Name="_zipSingleProject">
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>
103 <TestNugetProjectLockFile Include="$(ProjectLockJson)" Condition="Exists($(ProjectLockJson))"/>
104 <TestNugetProjectLockFile Include="$(TestRuntimeProjectLockJson)" Condition="Exists($(TestRuntimeProjectLockJson))"/>
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)"
114 ProjectLockFile="%(TestNugetProjectLockFile.FullPath)"
115 TargetMonikers="@(TestTargetFramework)">
116 <Output TaskParameter="ResolvedCopyLocalItems" ItemName="RequiredAssemblies" />
117 </PrereleaseResolveNuGetPackageAssets>
121 <AssemblyPaths Include="$([MSBuild]::MakeRelative($(PackagesDir), %(RequiredAssemblies.FullPath)))" />
122 <AssemblyFiles Include="@(RequiredAssemblies->'%(FileName)%(Extension)')"></AssemblyFiles>
123 <DupeAssemblies Include="%(AssemblyFiles.Identity)" Condition="'@(AssemblyFiles->Count())' > 1"> </DupeAssemblies>
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>
131 File="$(OutDir)/assemblylist.flat.txt"
132 Lines="@(UniqueAssemblyPaths)"
136 <GenerateAssemblyList
137 InputListLocation="$(OutDir)assemblylist.flat.txt"
138 OutputListLocation="$(OutDir)assemblylist.txt"
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"/>