1 <?xml version="1.0" encoding="utf-8"?>
2 <Project ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
4 <UsingTask TaskName="PrereleaseResolveNuGetPackageAssets" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
5 <UsingTask TaskName="RemoveDuplicatesWithLastOneWinsPolicy" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
6 <UsingTask TaskName="ZipFileCreateFromDirectory" Condition="'$(ArchiveTests)' == 'true'" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
7 <UsingTask TaskName="GenerateAssemblyList" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
8 <UsingTask TaskName="GetTargetMachineInfo" Condition="'$(TestWithLocalLibraries)'=='true'" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
11 <SerializeProjects Condition="'$(TestWithLocalLibraries)'=='true'">true</SerializeProjects>
15 Temporary until we have proper nuget support to deploy content files.
16 Copies supplemental test data to the build output and test directories.
18 <Target Name="CopySupplementalTestData" DependsOnTargets="DiscoverTestInputs">
19 <!-- coalesce supplemental test data items with and without DestinationDir metadata -->
21 <_SupplementalTestData Include="@(SupplementalTestData)" Condition="'%(DestinationDir)' != ''">
22 <DestinationDir>%(DestinationDir)</DestinationDir>
23 </_SupplementalTestData>
24 <_SupplementalTestData Include="@(SupplementalTestData)" Condition="'%(DestinationDir)' == ''">
25 <DestinationDir>%(RecursiveDir)</DestinationDir>
26 </_SupplementalTestData>
29 <SupplementalTestDataTestDir Include="@(_SupplementalTestData->'$(TestPath)/%(DestinationDir)%(Filename)%(Extension)')" />
30 <SupplementalTestDataOutDir Include="@(_SupplementalTestData->'$(OutDir)%(DestinationDir)%(Filename)%(Extension)')" />
33 SourceFiles="@(_SupplementalTestData)"
34 DestinationFiles="@(SupplementalTestDataTestDir)"
35 SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
36 OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
37 Retries="$(CopyRetryCount)"
38 RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
39 UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
41 <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
44 SourceFiles="@(_SupplementalTestData)"
45 DestinationFiles="@(SupplementalTestDataOutDir)"
46 SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
47 OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
48 Retries="$(CopyRetryCount)"
49 RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
50 UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
52 <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
56 <!-- Workaround for VS execution: This will form the same list and copy the same files as
57 copied via RunTests script so VS can work when the test dir is initially clean.
59 <PropertyGroup Condition="'$(BuildingInsideVisualStudio)'=='true'">
60 <PrepareForRunDependsOn>$(PrepareForRunDependsOn);CopyDefaultTestAssetsForVS</PrepareForRunDependsOn>
62 <Target Name="CopyDefaultTestAssetsForVS" DependsOnTargets="DiscoverTestInputs;CopySupplementalTestData">
63 <!-- This was copied from RunTestsForProject in tests.targets
64 The RunTestsForProject target does not execute in VS context and would be confused by the script based runner.
65 _TestCopyLocalByFileNameWithoutDuplicates are the precise items that are fed to the runner script generation code.
68 <!-- Not all platforms can use the .ni.dlls that come from packages. If TestWithoutNativeImages is specified, we'll exclude them from copy generation.
69 If we end up needing this for any other sorts of filtering, we'll want to add a list of filtered extensions to be matched on EndsWith. -->
70 <_IncludedFileForTestsInVS Include="@(_TestCopyLocalByFileNameWithoutDuplicates)"
71 Condition="'$(TestWithoutNativeImages)' != 'true' Or !$([System.String]::Copy('%(_TestCopyLocalByFileNameWithoutDuplicates.SourcePath)').EndsWith('.ni.dll'))" >
72 <PackageRelativePath Condition="'%(_TestCopyLocalByFileNameWithoutDuplicates.NugetPackageId)' != ''">$([System.String]::Copy('%(_TestCopyLocalByFileNameWithoutDuplicates.SourcePath)').Replace('$(PackagesDir)',''))</PackageRelativePath>
73 <UseAbsolutePath Condition="'$(TestWithLocalLibraries)'=='true'">$([System.String]::Copy('%(_TestCopyLocalByFileNameWithoutDuplicates.SourcePath)').StartsWith('$(BinDir)'))</UseAbsolutePath>
74 <DestinationPath>$(TestPath)\%(Filename)%(Extension)</DestinationPath>
75 </_IncludedFileForTestsInVS>
76 <_IncludedFileForTestsInVs Remove="@(_IncludedFileForTestsInVS)" Condition="Exists('%(DestinationPath)')" />
80 SourceFiles="@(_IncludedFileForTestsInVS -> '%(SourcePath)')"
81 DestinationFiles="@(_IncludedFileForTestsInVS->'%(DestinationPath)')"
82 SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
83 OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
84 Retries="$(CopyRetryCount)"
85 RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
86 UseHardlinksIfPossible="true">
87 <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
91 <!-- archive the test binaries along with some supporting files -->
92 <Target Name="ArchiveTestBuild"
93 Condition="'$(ArchiveTests)' == 'true'"
94 DependsOnTargets="GenerateTestExecutionScripts">
96 <TestArchiveDir>$(TestWorkingDir)$(OSPlatformConfig)/archive/tests/$(TargetOutputRelPath)</TestArchiveDir>
97 <ProjectJson Condition="!Exists('$(ProjectJson)')">$(OriginalProjectJson)</ProjectJson>
99 <PropertyGroup Condition="'$(TestProjectName)'==''">
100 <TestProjectName>$(MSBuildProjectName)</TestProjectName>
103 <!-- the project json and runner script files need to be included in the archive -->
104 <Copy SourceFiles="$(ProjectJson);$(ProjectLockJson)" DestinationFolder="$(TestPath)" />
105 <MakeDir Directories="$(TestArchiveDir)" />
106 <ZipFileCreateFromDirectory SourceDirectory="$(TestPath)" DestinationArchive="$(TestArchiveDir)$(TestProjectName).zip" OverwriteDestination="true" />