Use ProjectReference to build against System.Private.CoreLib (#38196)
authorViktor Hofer <viktor.hofer@microsoft.com>
Mon, 22 Jun 2020 17:53:00 +0000 (19:53 +0200)
committerGitHub <noreply@github.com>
Mon, 22 Jun 2020 17:53:00 +0000 (19:53 +0200)
* Use ProjectReference to build against CoreLib

44 files changed:
src/libraries/Directory.Build.props
src/libraries/Directory.Build.targets
src/libraries/System.AppContext/src/System.AppContext.csproj
src/libraries/System.Buffers/src/System.Buffers.csproj
src/libraries/System.Collections.Concurrent/src/System.Collections.Concurrent.csproj
src/libraries/System.Collections/src/System.Collections.csproj
src/libraries/System.Diagnostics.Contracts/src/System.Diagnostics.Contracts.csproj
src/libraries/System.Diagnostics.Debug/src/System.Diagnostics.Debug.csproj
src/libraries/System.Diagnostics.Debug/tests/System.Diagnostics.Debug.Tests.csproj
src/libraries/System.Diagnostics.StackTrace/src/System.Diagnostics.StackTrace.csproj
src/libraries/System.Diagnostics.Tools/src/System.Diagnostics.Tools.csproj
src/libraries/System.Diagnostics.TraceSource/src/System.Diagnostics.TraceSource.csproj
src/libraries/System.Diagnostics.Tracing/src/System.Diagnostics.Tracing.csproj
src/libraries/System.Globalization.Calendars/src/System.Globalization.Calendars.csproj
src/libraries/System.Globalization/src/System.Globalization.csproj
src/libraries/System.IO.UnmanagedMemoryStream/src/System.IO.UnmanagedMemoryStream.csproj
src/libraries/System.Memory/src/System.Memory.csproj
src/libraries/System.Numerics.Vectors/src/System.Numerics.Vectors.csproj
src/libraries/System.Private.Uri/src/System.Private.Uri.csproj
src/libraries/System.Reflection.Emit.ILGeneration/src/System.Reflection.Emit.ILGeneration.csproj
src/libraries/System.Reflection.Emit.Lightweight/src/System.Reflection.Emit.Lightweight.csproj
src/libraries/System.Reflection.Emit/src/System.Reflection.Emit.csproj
src/libraries/System.Reflection.Primitives/src/System.Reflection.Primitives.csproj
src/libraries/System.Reflection.TypeExtensions/src/System.Reflection.TypeExtensions.csproj
src/libraries/System.Reflection/src/System.Reflection.csproj
src/libraries/System.Resources.ResourceManager/src/System.Resources.ResourceManager.csproj
src/libraries/System.Runtime.Extensions/src/System.Runtime.Extensions.csproj
src/libraries/System.Runtime.InteropServices/src/System.Runtime.InteropServices.csproj
src/libraries/System.Runtime.Intrinsics/src/System.Runtime.Intrinsics.csproj
src/libraries/System.Runtime.Loader/src/System.Runtime.Loader.csproj
src/libraries/System.Runtime.Serialization.Formatters/src/System.Runtime.Serialization.Formatters.csproj
src/libraries/System.Runtime/src/System.Runtime.csproj
src/libraries/System.Security.Principal/src/System.Security.Principal.csproj
src/libraries/System.Text.Encoding.Extensions/src/System.Text.Encoding.Extensions.csproj
src/libraries/System.Text.Encoding/src/System.Text.Encoding.csproj
src/libraries/System.Threading.Overlapped/src/System.Threading.Overlapped.csproj
src/libraries/System.Threading.Tasks.Extensions/src/System.Threading.Tasks.Extensions.csproj
src/libraries/System.Threading.Tasks/src/System.Threading.Tasks.csproj
src/libraries/System.Threading.Thread/src/System.Threading.Thread.csproj
src/libraries/System.Threading.ThreadPool/src/System.Threading.ThreadPool.csproj
src/libraries/System.Threading.Timer/src/System.Threading.Timer.csproj
src/libraries/System.Threading/src/System.Threading.csproj
src/libraries/System.Utf8String.Experimental/src/System.Utf8String.Experimental.csproj
src/libraries/shims/manual/Directory.Build.props

index 9a7f6ea..2bf7926 100644 (file)
     <NetStandard21RefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', 'netstandard2.1'))</NetStandard21RefPath>
     <NetFxRefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', '$(NetFrameworkCurrent)'))</NetFxRefPath>
 
+    <!-- System.Private.CoreLib -->
+    <CoreLibProject Condition="'$(RuntimeFlavor)' == 'CoreCLR'">$([MSBuild]::NormalizePath('$(CoreClrProjectRoot)', 'src', 'System.Private.CoreLib', 'System.Private.CoreLib.csproj'))</CoreLibProject>
+    <CoreLibProject Condition="'$(RuntimeFlavor)' == 'Mono'">$([MSBuild]::NormalizePath('$(MonoProjectRoot)', 'netcore', 'System.Private.CoreLib', 'System.Private.CoreLib.csproj'))</CoreLibProject>
+
     <!-- Helix properties -->
     <OSPlatformConfig>$(TargetOS).$(Platform).$(Configuration)</OSPlatformConfig>
     <AnyOSPlatformConfig>AnyOS.AnyCPU.$(Configuration)</AnyOSPlatformConfig>
index 520de08..728194d 100644 (file)
@@ -1,4 +1,4 @@
-<Project InitialTargets="AddSkipGetTargetFrameworkToProjectReferences">
+<Project InitialTargets="UpdateProjectReferencesWithAttributes">
   <PropertyGroup>
     <RefPath>$([MSBuild]::NormalizeDirectory('$(RefRootPath)', '$(TargetFramework)'))</RefPath>  
   </PropertyGroup>
   <!-- Define this target to override the workaround in arcade as we don't need it for our pkgprojs -->
   <Target Name="InitializeStandardNuspecProperties" />
 
-  <Target Name="AddSkipGetTargetFrameworkToProjectReferences" Condition="'@(ProjectReference)' != ''">
+  <Target Name="UpdateProjectReferencesWithAttributes" Condition="'@(ProjectReference)' != ''">
     <ItemGroup>
       <ProjectReference>
         <SkipGetTargetFrameworkProperties>true</SkipGetTargetFrameworkProperties>
+        <AdditionalProperties Condition="'%(Filename)' == 'System.Private.CoreLib' and '$(RuntimeFlavor)' == 'CoreCLR'">Configuration=$(CoreCLRConfiguration);TargetFramework=$(NetCoreAppCurrent)</AdditionalProperties>
+        <AdditionalProperties Condition="'%(Filename)' == 'System.Private.CoreLib' and '$(RuntimeFlavor)' == 'Mono'">Configuration=$(MonoConfiguration);TargetFramework=$(NetCoreAppCurrent)</AdditionalProperties>
       </ProjectReference>
     </ItemGroup>
   </Target>
index 5e8bc46..0b924ac 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index d8c3ac0..7e9aff4 100644 (file)
@@ -7,6 +7,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 6275b7b..93f3a50 100644 (file)
@@ -22,7 +22,7 @@
              Link="System\Collections\Concurrent\IProducerConsumerCollectionDebugView.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
     <ProjectReference Include="..\..\System.Collections\src\System.Collections.csproj" />
     <ProjectReference Include="..\..\System.Diagnostics.Tracing\src\System.Diagnostics.Tracing.csproj" />
     <ProjectReference Include="..\..\System.Threading\src\System.Threading.csproj" />
index 5c53300..7ac5006 100644 (file)
@@ -33,6 +33,6 @@
              Link="Common\System\Collections\Generic\EnumerableHelpers.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index d36d38d..2e459ec 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index ed90575..b7a84d2 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index b97ec7f..4d90da9 100644 (file)
@@ -9,7 +9,7 @@
   <ItemGroup>
     <DefaultReferenceExclusions Include="System.Diagnostics.Debug" />
     <DefaultReferenceExclusions Include="System.Runtime.Extensions" />
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" Private="false" />
     <ReferenceFromRuntime Include="System.Runtime" />
     <ReferenceFromRuntime Include="System.Threading" />
   </ItemGroup>
index 49a5b48..f7f1a5c 100644 (file)
@@ -34,6 +34,6 @@
     <ProjectReference Include="..\..\System.Collections.Immutable\src\System.Collections.Immutable.csproj" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 576e6bc..7e81318 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 9db54bc..78c3994 100644 (file)
@@ -61,6 +61,6 @@
     <ProjectReference Include="..\..\System.Threading\src\System.Threading.csproj" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 58a09ce..bae87cb 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index bf86520..c251f69 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index d6b2cea..4dacec6 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index d48bece..af6feb1 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 91a282e..b9f9e1e 100644 (file)
@@ -38,6 +38,6 @@
              Link="Common\System\Buffers\ArrayBufferWriter.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 2bdbc1f..dd3dc29 100644 (file)
@@ -5,6 +5,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index b69a696..d53e602 100644 (file)
@@ -43,6 +43,6 @@
     <Compile Include="System\Uri.Unix.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index cadec53..7294575 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 689898b..2747800 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 08c3fd8..4f2d15a 100644 (file)
@@ -5,6 +5,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 3fbef4c..5c3faa5 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index a64ce6f..058466c 100644 (file)
@@ -11,6 +11,6 @@
     <Compile Include="System\Reflection\TypeExtensions.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 687edd4..dff84ed 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 8dc3c8e..61a965e 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 0aa03e9..8919fbb 100644 (file)
@@ -11,6 +11,6 @@
     <ProjectReference Include="..\..\System.Runtime\src\System.Runtime.csproj" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 6559e17..213c543 100644 (file)
@@ -50,6 +50,6 @@
     <Compile Include="System\Security\SecureStringMarshal.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 2bdbc1f..dd3dc29 100644 (file)
@@ -5,6 +5,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index ef3bbf8..2697388 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 3fbf7cc..cc6da0e 100644 (file)
@@ -58,7 +58,7 @@
              Link="Common\System\Collections\HashHelpers.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
     <ProjectReference Include="..\..\System.Runtime.CompilerServices.Unsafe\src\System.Runtime.CompilerServices.Unsafe.ilproj" />
     <ProjectReference Include="..\..\System.Runtime\src\System.Runtime.csproj" />
     <ProjectReference Include="..\..\System.Collections\src\System.Collections.csproj" />
index 4d0b209..3b083ac 100644 (file)
@@ -16,6 +16,6 @@
     <ProjectReference Include="..\..\System.Private.Uri\src\System.Private.Uri.csproj" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 6fe4e14..d9b7db3 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 813d9a7..bc0555c 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 9c5ec3a..16ab188 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 47c0075..a5c9c0d 100644 (file)
@@ -7,6 +7,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 08c3fd8..4f2d15a 100644 (file)
@@ -5,6 +5,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 656789e..1b8aa10 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index ca83b0f..7bde58c 100644 (file)
@@ -7,6 +7,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 572f893..14a425e 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
\ No newline at end of file
index 7dde2ec..68aff54 100644 (file)
@@ -6,6 +6,6 @@
     <Nullable>enable</Nullable>
   </PropertyGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 6b31afd..6b4aeb5 100644 (file)
@@ -18,6 +18,6 @@
              Link="Common\System\HResults.cs" />
   </ItemGroup>
   <ItemGroup>
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
 </Project>
index 8c12e12..4fb47cb 100644 (file)
     <Reference Include="System.Security.Cryptography.Algorithms" />
   </ItemGroup>
   <ItemGroup Condition="'$(TargetFramework)' == '$(NetCoreAppCurrent)'">
-    <ReferenceFromRuntime Include="System.Private.CoreLib" />
+    <ProjectReference Include="$(CoreLibProject)" />
     <Reference Include="System.Net.Http" />
     <Reference Include="System.Net.Primitives" />
     <ProjectReference Include="..\..\System.Runtime\src\System.Runtime.csproj" />
index e227dbf..ee66f30 100644 (file)
   </PropertyGroup>
 
   <ItemGroup>
-    <ReferencePath
-      Include="$(RuntimePath)System.*.dll;$(RuntimePath)Microsoft.Win32.*.dll;$(RuntimePath)netstandard.dll"
-      Exclude="$(RuntimePath)$(MSBuildProjectName).dll" />
+    <ReferencePath Include="$(RuntimePath)System.*.dll;$(RuntimePath)Microsoft.Win32.*.dll;$(RuntimePath)netstandard.dll"
+                   Exclude="$(RuntimePath)$(MSBuildProjectName).dll" />
+    <ProjectReference Include="$(CoreLibProject)" />
   </ItemGroup>
-
-  <Target Name="AddSystemPrivateCoreLibReferencePath" DependsOnTargets="GetFilesFromRuntime" BeforeTargets="ResolveReferences">
-    <ItemGroup>
-      <ReferencePath Include="@(RuntimeFiles)" Condition="'%(FileName)%(Extension)' == 'System.Private.CoreLib.dll'" />
-    </ItemGroup>
-  </Target>
 </Project>