summaryrefslogtreecommitdiff
path: root/tests/xunitwrapper.targets
blob: 3b343bd891194094c02473bae28d9706da4db2c8 (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
<?xml version="1.0" encoding="utf-8"?>
<!-- This overrides the typical ResolveNuGetPackages so that it does copy local of the
     referenced items.  This is used so that we can correctly resolve and copy the libraries necessary
     to the core_root directory -->

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Target Name="ResolveNuGetPackages">
 
    <PrereleaseResolveNuGetPackageAssets Condition="Exists($(ProjectLockJson))"
                                         AllowFallbackOnTargetSelection="true"
                                         IncludeFrameworkReferences="false"
                                         NuGetPackagesDirectory="$(PackagesDir)"
                                         RuntimeIdentifier="$(TestNugetRuntimeId)"
                                         ProjectLanguage="$(Language)"
                                         ProjectLockFile="$(ProjectLockJson)"
                                         TargetMonikers="$(TargetFrameworkMoniker)">
      <Output TaskParameter="ResolvedAnalyzers" ItemName="Analyzer" />
      <Output TaskParameter="ResolvedReferences" ItemName="Reference" />
      <Output TaskParameter="ResolvedCopyLocalItems" ItemName="CopyLocal" />
    </PrereleaseResolveNuGetPackageAssets>

    <!-- We may have an indirect package reference that we want to replace with a project reference -->
    <ItemGroup>
      <!-- Convert to file names so that we can intersect -->
      <_ProjectReferenceFilenames Include="@(_ResolvedProjectReferencePaths->'%(FileName)%(Extension)')">
        <OriginalIdentity>%(Identity)</OriginalIdentity>
      </_ProjectReferenceFilenames>

      <_ReferencesFileNames Include="@(Reference->'%(FileName)%(Extension)')">
        <OriginalIdentity>%(Identity)</OriginalIdentity>
      </_ReferencesFileNames>

      <_CopyLocalFileNames Include="@(CopyLocal->'%(FileName)%(Extension)')">
        <OriginalIdentity>%(Identity)</OriginalIdentity>
      </_CopyLocalFileNames>
      
      <!-- Intersect project-refs with package-refs -->
      <_ReferenceFileNamesToRemove Include="@(_ReferencesFileNames->'%(OriginalIdentity)')" Condition="'@(_ProjectReferenceFilenames)' == '@(_ReferencesFileNames)' and '%(Identity)' != ''"/>
      <_CopyLocalFileNamesToRemove Include="@(_CopyLocalFileNames->'%(OriginalIdentity)')" Condition="'@(_ProjectReferenceFilenames)' == '@(_CopyLocalFileNames)' and '%(Identity)' != ''"/>

      <Reference Remove="@(_ReferenceFileNamesToRemove)" />
      <CopyLocal Remove="@(_CopyLocalFileNamesToRemove)"/>
    </ItemGroup>
    
    <Message Text="Excluding @(_ReferenceFileNamesToRemove);@(_CopyLocalFileNamesToRemove) from package references since the same file is provided by a project reference."
             Condition="'@(_ReferenceFileNamesToRemove)' != '' or '@(_CopyLocalFileNamesToRemove)' != ''"/>
             
    <Copy
      SourceFiles="@(CopyLocal)"
      DestinationFolder="$(OutDir)"
      SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
      OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
      Retries="$(CopyRetryCount)"
      RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
      UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)">
      
      <Output TaskParameter="DestinationFiles" ItemName="FileWrites" />
    </Copy>
    
  </Target>
</Project>