summaryrefslogtreecommitdiff
path: root/Tools/publishtest.targets
blob: a5c5ee0dd08e4990145c6aa0b853a038e8eb95ef (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">

  <UsingTask TaskName="PrereleaseResolveNuGetPackageAssets" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
  <UsingTask TaskName="RemoveDuplicatesWithLastOneWinsPolicy" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
  <UsingTask TaskName="ZipFileCreateFromDirectory" Condition="'$(ArchiveTests)' == 'true'" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
  <UsingTask TaskName="GenerateAssemblyList" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>
  <UsingTask TaskName="GetTargetMachineInfo" Condition="'$(TestWithLocalLibraries)'=='true'" AssemblyFile="$(BuildToolsTaskDir)Microsoft.DotNet.Build.Tasks.dll"/>

  <PropertyGroup>
    <SerializeProjects Condition="'$(TestWithLocalLibraries)'=='true'">true</SerializeProjects>
  </PropertyGroup>

  <!-- Binplace dirs for the supplemental test data. -->
  <ItemGroup>
    <SupplementalTestDataDir Include="$(TestPath)" />
    <SupplementalTestDataDir Include="$(OutDir)" />
  </ItemGroup>

  <!-- Copy supplemental test files into specified test directories. -->
  <Target Name="CopySupplementalTestData"
          DependsOnTargets="DiscoverTestInputs"
          Inputs="@(SupplementalTestDataDir);%(SupplementalTestDataDir.Identity)"
          Outputs="unused">

    <PropertyGroup>
      <_SupplementalTestDataDir>%(SupplementalTestDataDir.Identity)</_SupplementalTestDataDir>
    </PropertyGroup>

    <ItemGroup>
      <_SupplementalTestData Include="@(SupplementalTestData)">
        <DestinationDir Condition="'%(SupplementalTestData.DestinationDir)' == ''">%(RecursiveDir)</DestinationDir>
        <DestinationName Condition="'%(SupplementalTestData.DestinationName)' == ''">%(Filename)%(Extension)</DestinationName>
      </_SupplementalTestData>
    </ItemGroup>

    <Copy SourceFiles="@(_SupplementalTestData)"
          DestinationFiles="@(_SupplementalTestData -> '$([MSBuild]::NormalizePath('$(_SupplementalTestDataDir)', '%(DestinationDir)', '%(DestinationName)'))')"
          SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
          OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
          Retries="$(CopyRetryCount)"
          RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
          UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
      <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
    </Copy>

  </Target>

    <!-- archive the test binaries along with some supporting files -->
  <Target Name="ArchiveTestBuild"
          Condition="'$(ArchiveTests)' == 'true'"
          DependsOnTargets="GenerateTestExecutionScripts">
    <PropertyGroup>
      <TestArchiveDir>$(TestWorkingDir)$(OSPlatformConfig)/archive/tests/$(TargetOutputRelPath)</TestArchiveDir>
      <ProjectJson Condition="!Exists('$(ProjectJson)')">$(OriginalProjectJson)</ProjectJson>
    </PropertyGroup>
    <PropertyGroup Condition="'$(TestProjectName)'==''">
      <TestProjectName>$(MSBuildProjectName)</TestProjectName>
    </PropertyGroup>

    <!-- the project json and runner script files need to be included in the archive -->
    <Copy SourceFiles="$(ProjectJson);$(ProjectLockJson)" DestinationFolder="$(TestPath)" />
    <MakeDir Directories="$(TestArchiveDir)" />
    <ZipFileCreateFromDirectory SourceDirectory="$(TestPath)" DestinationArchive="$(TestArchiveDir)$(TestProjectName).zip" OverwriteDestination="true" />
  </Target>

</Project>