summaryrefslogtreecommitdiff
path: root/tests/src/Common/CoreFX/CoreFX.depproj
blob: fc61e1dd5bce15a43f5a170694dc0ad18c03efb7 (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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="Build">
  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.props))\dir.props" />
  <PropertyGroup>
      <RestoreOutputPath>$(SourceDir)Common\CoreFX\obj</RestoreOutputPath>
      <Language>C#</Language>
      <NugetTargetMoniker>.NETCoreApp,Version=v3.1</NugetTargetMoniker>
      <TargetFramework>netcoreapp3.1</TargetFramework>
      <RuntimeFrameworkVersion>$(MicrosoftNETCoreAppVersion)</RuntimeFrameworkVersion>
      <ContainsPackageReferences>true</ContainsPackageReferences>
      <CLRTestKind>SharedLibrary</CLRTestKind>
      <IsTestProject>false</IsTestProject>
      <MicrosoftDiagnosticsRuntimePackageVersion>1.0.5</MicrosoftDiagnosticsRuntimePackageVersion>
  </PropertyGroup>

  <!-- Switch RuntimeIdentifier according to currently targeted OSGroup -->
  <PropertyGroup>
      <RuntimeIdentifier Condition="'$(OSGroup)' == 'Windows_NT'">win-$(Platform)</RuntimeIdentifier>
      <RuntimeIdentifier Condition="'$(OSGroup)' == 'Linux'">linux-$(Platform)</RuntimeIdentifier>
      <RuntimeIdentifier Condition="'$(OSGroup)' == 'OSX'">osx-$(Platform)</RuntimeIdentifier>
      <NugetRuntimeIdentifier>$(RuntimeIdentifier)</NugetRuntimeIdentifier>

      <!-- Set AdditionalRestoreArgs so the _DnuRestoreCommandFull in Tools\packageresolve.targets
           passes these on to 'dotnet restore'. This is needed so all the various dirs.props files
           set up the target architecture correctly, so $(Platform) above gets set correctly, among
           other things. (Note that _DnuRestoreCommandFull doesn't properly set
           TargetGroup/ConfigurationGroup/ArchGroup, and even if they are set, it isn't used by
           the various dirs.props files.)
      -->
      <AdditionalRestoreArgs>/p:__BuildOS=$(__BuildOS) /p:__BuildType=$(__BuildType) /p:__BuildArch=$(__BuildArch)</AdditionalRestoreArgs>
  </PropertyGroup>

  <ItemGroup>

    <!-- Workaround to exclude runtime assets from this package while we fix a bug in CoreFx -->
    <PackageReference Include="System.IO.FileSystem.AccessControl" Version="$(SystemIOFileSystemAccessControlVersion)" ExcludeAssets="Runtime" />

    <!-- Microsoft.Private.CoreFx.OOB is a meta-package that contains references to most of what we need -->
    <PackageReference Include="Microsoft.Private.CoreFx.OOB" Version="$(MicrosoftPrivateCoreFxNETCoreAppVersion)" />

    <!-- dotnet.exe -->
    <PackageReference Include="Microsoft.NETCore.DotNetHost" Version="$(MicrosoftNETCoreAppVersion)" />

    <!-- hostfxr.dll -->
    <PackageReference Include="Microsoft.NETCore.DotNetHostResolver" Version="$(MicrosoftNETCoreAppVersion)" />

    <!-- hostpolicy.dll -->
    <PackageReference Include="Microsoft.NETCore.DotNetHostPolicy" Version="$(MicrosoftNETCoreAppVersion)" />

  </ItemGroup>

  <!-- Target SetupTestingHost needs to run after "AfterResolveReferences" so @(ReferenceCopyLocalPaths) is
       set up, and before "BeforeCompile" because @(ReferenceCopyLocalPaths) is cleared out during the
       compile phase.
  -->
  <Target Name="SetupTestingHost" AfterTargets="AfterResolveReferences" BeforeTargets="BeforeCompile">

    <Error Condition="'$(CORE_ROOT)' == ''"
           Text="CORE_ROOT variable is not set." />

    <PropertyGroup Condition="'$(OSGroup)'=='Windows_NT'">
      <HostFxrFileName>hostfxr</HostFxrFileName>
      <HostFxrFileExtension>dll</HostFxrFileExtension>
      <DotnetExecutableName>dotnet.exe</DotnetExecutableName>
      <HostPolicyFileName>hostpolicy</HostPolicyFileName>
      <HostPolicyExtension>dll</HostPolicyExtension>
    </PropertyGroup>

    <PropertyGroup Condition="'$(OSGroup)'!='Windows_NT'">
      <HostFxrFileName>libhostfxr</HostFxrFileName>
      <HostFxrFileExtension Condition="'$(OSGroup)' == 'Linux' Or '$(OSGroup)' == 'FreeBSD'">so</HostFxrFileExtension>
      <HostFxrFileExtension Condition="$(OSGroup) =='OSX'">dylib</HostFxrFileExtension>
      <HostPolicyFileName>libhostpolicy</HostPolicyFileName>
      <HostPolicyExtension>$(HostFxrFileExtension)</HostPolicyExtension>
      <DotnetExecutableName>dotnet</DotnetExecutableName>
    </PropertyGroup>

    <ItemGroup>
      <!-- Workaround for packages on which Microsoft.NetCoreApp expresses a dependency
           The <PackageToInclude> element doesn't allow a version to be specified and we end up with clashing assembly versions in Core_Root
      -->
      <!--
      <NetCoreAppPackagedAssemblies Include="System.Text.Encoding.CodePages.dll"/>
      -->

      <!-- Use xunit dependencies defined in CoreFX.depproj instead of conflicting versions from test dependencies. -->
      <TestDependenciesToExclude Include="$(CORE_ROOT)\**\xunit*"/>

      <!-- Exclude subdirectories that contain cross-architecture (possibly cross-bitness) crossgen/JIT -->
      <TestDependenciesToExclude Include="$(CORE_ROOT)\**\x64\*"/>

      <!-- Don't include all the nuget files -->
      <TestDependenciesToExclude Include="$(CORE_ROOT)\.nuget\**\*"/>

      <CoreCLRBinariesToExclude Include="@(NetCoreAppPackagedAssemblies);@(TestDependenciesToExclude -> '%(Identity)')" />
    </ItemGroup>

    <ItemGroup>
      <!-- REVIEW: do we need to copy recursively (and flatten the structure into a single destination folder)? Can we just copy
           the top level? Or, should we preserve the hierarchy?
      -->
      <CoreCLRBinaries Include="$(CORE_ROOT)\**\*.*" Exclude="$(CORE_ROOT)\**\@(CoreCLRBinariesToExclude -> '%(Identity)' )" />
    </ItemGroup>

    <ItemGroup>
      <HostFxFile Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Filename)' == '$(HostFxrFileName)'" />
      <DotnetExe Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Filename)' == 'dotnet'" />
      <HostPolicyFile Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Filename)' == '$(HostPolicyFileName)'" />
    </ItemGroup>

    <Copy SourceFiles="@(HostFxFile)"
          DestinationFolder="$(NETCoreAppTestHostFxrPath)"
          SkipUnchangedFiles="true"
          UseHardlinksIfPossible="true" />

    <Copy SourceFiles="@(HostPolicyFile)"
          DestinationFolder="$(NETCoreAppTestSharedFrameworkPath)"
          SkipUnchangedFiles="true"
          UseHardlinksIfPossible="true" />

    <Copy SourceFiles="@(DotnetExe)"
          DestinationFolder="$(TestHostRootPath)"
          SkipUnchangedFiles="true"
          UseHardlinksIfPossible="true"  />

    <Copy SourceFiles="@(CoreCLRBinaries)"
          DestinationFolder="$(NETCoreAppTestSharedFrameworkPath)"
          SkipUnchangedFiles="true" />

    <Exec Command="chmod +x $(TestHostRootPath)%(DotnetExe.Filename)%(DotnetExe.Extension)" Condition="'$(OSGroup)' != 'Windows_NT'"/>
  </Target>

  <Import Project="$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), dir.targets))\dir.targets" />

  <PropertyGroup>
    <ProjectAssetsFile>$(SourceDir)Common\CoreFX\obj\project.assets.json</ProjectAssetsFile>
  </PropertyGroup>
</Project>