Remove netstandard1.x dependencies
Description
Targeting netstandard1.x is now discouraged with the latest .NET SDK. .NET source-build would like to eliminate netstandard1.x references in order to unblock some infrastructure improvements.
The only netstandard1.x references came from the Microsoft.TestPlatform.CoreUtilities.csproj project. These references were upgraded to eliminate the netstandard1.x references .
Related issue
Related to https://github.com/dotnet/source-build/issues/4482
cc @ViktorHofer
@nohwnd - Can you review or loop in the right folks to review? TIA
I will review, last time I looked at this the build was failing so I was not sure if you will make more changes. :)
I will review, last time I looked at this the build was failing so I was not sure if you will make more changes. :)
Thanks - It was not clear to me how the test failure was related to these changes. I triggered a re-run and will investigate further if it is still failing. I may need some help.
/azp run
Azure Pipelines successfully started running 1 pipeline(s).
/azp run
Azure Pipelines successfully started running 1 pipeline(s).
@MichaelSimons I looked at your changes and noticed a few packages are referenced on .NETCoreApp but which shouldn't be referenced at all. I created this patch:
diff --git a/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj b/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj
index cedef35f5..09073c688 100644
--- a/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj
+++ b/src/Microsoft.TestPlatform.CoreUtilities/Microsoft.TestPlatform.CoreUtilities.csproj
@@ -16,12 +16,12 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
- <ItemGroup Condition=" '$(TargetFramework)' != '$(NetFrameworkMinimum)' ">
+ <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0' or '$(TargetFramework)' == 'netcoreapp3.1'">
<PackageReference Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" />
</ItemGroup>
- <ItemGroup>
- <PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
+ <ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
+ <PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
</ItemGroup>
<ItemGroup>
diff --git a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Microsoft.TestPlatform.Extensions.TrxLogger.csproj b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Microsoft.TestPlatform.Extensions.TrxLogger.csproj
index 8396da2fe..8495cad62 100644
--- a/src/Microsoft.TestPlatform.Extensions.TrxLogger/Microsoft.TestPlatform.Extensions.TrxLogger.csproj
+++ b/src/Microsoft.TestPlatform.Extensions.TrxLogger/Microsoft.TestPlatform.Extensions.TrxLogger.csproj
@@ -40,7 +40,7 @@
<ProjectReference Include="$(RepoRoot)src\Microsoft.TestPlatform.CoreUtilities\Microsoft.TestPlatform.CoreUtilities.csproj" />
</ItemGroup>
- <ItemGroup Condition=" '$(TargetFramework)' != '$(NetFrameworkMinimum)' ">
+ <ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" />
</ItemGroup>
diff --git a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj
index 9278611cb..3efc66d63 100644
--- a/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj
+++ b/src/Microsoft.TestPlatform.ObjectModel/Microsoft.TestPlatform.ObjectModel.csproj
@@ -32,8 +32,8 @@
<Reference Include="Microsoft.CSharp" />
</ItemGroup>
- <ItemGroup>
- <PackageReference Include="System.Reflection.Metadata" Version="1.6.0" />
+ <ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
+ <PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" />
</ItemGroup>
<ItemGroup>
diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj b/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj
index 5aae32c1c..c99696737 100644
--- a/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj
+++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Microsoft.TestPlatform.PlatformAbstractions.csproj
@@ -9,16 +9,6 @@
<NoWarn>$(NoWarn);NU1605</NoWarn>
</PropertyGroup>
- <ItemGroup Condition=" '$(TargetFramework)' == '$(NetCoreAppMinimum)' ">
- <PackageReference Include="System.Threading.Thread" Version="4.0.0" />
- <PackageReference Include="System.Diagnostics.Process" Version="4.1.0" />
- <PackageReference Include="System.Diagnostics.TextWriterTraceListener" Version="4.0.0" />
- <PackageReference Include="System.Diagnostics.TraceSource" Version="4.0.0" />
- <PackageReference Include="System.Runtime.InteropServices.RuntimeInformation" Version="4.0.0" />
- <PackageReference Include="System.Runtime.Loader" Version="4.0.0" />
- <PackageReference Include="System.Net.Http" Version="$(SystemNetHttpVersion)" />
- </ItemGroup>
-
<ItemGroup Condition=" '$(TargetFramework)' == '$(NetFrameworkMinimum)' ">
<Reference Include="System.Configuration" />
<Reference Include="System" />
diff --git a/src/Microsoft.TestPlatform.TestHostProvider/Microsoft.TestPlatform.TestHostProvider.csproj b/src/Microsoft.TestPlatform.TestHostProvider/Microsoft.TestPlatform.TestHostProvider.csproj
index 8191a31a2..faa6f6814 100644
--- a/src/Microsoft.TestPlatform.TestHostProvider/Microsoft.TestPlatform.TestHostProvider.csproj
+++ b/src/Microsoft.TestPlatform.TestHostProvider/Microsoft.TestPlatform.TestHostProvider.csproj
@@ -26,7 +26,7 @@
<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" />
- <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
+ <PackageReference Include="System.Runtime.CompilerServices.Unsafe" Version="4.7.1" Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'" />
</ItemGroup>
<ItemGroup>
<Compile Update="NullableHelpers.cs">
diff --git a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj
index 731242151..ed399f1ce 100644
--- a/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj
+++ b/src/package/Microsoft.TestPlatform.CLI/Microsoft.TestPlatform.CLI.csproj
@@ -61,17 +61,21 @@
<ItemGroup>
<PackageReference Include="System.ComponentModel.Composition" Version="$(SystemComponentModelCompositionVersion)" GeneratePathProperty="true" />
- <PackageReference Include="System.Security.AccessControl" Version="$(SystemSecurityAccessControlVersion)" GeneratePathProperty="true" PrivateAssets="Runtime" />
- <PackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" GeneratePathProperty="true" PrivateAssets="All" />
<PackageReference Include="Microsoft.CodeCoverage.IO" Version="$(MicrosoftCodeCoverageIOVersion)" GeneratePathProperty="true" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsFileSystemGlobbingVersion)" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Diagnostics.NETCore.Client" Version="$(MicrosoftDiagnosticsNETCoreClientVersion)" PrivateAssets="All" GeneratePathProperty="true" />
<PackageReference Include="Microsoft.Internal.Dia" Version="$(TestPlatformMSDiaVersion)" PrivateAssets="All" GeneratePathProperty="true" Condition="'$(TargetFramework)'=='net472'" />
- <PackageReference Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" GeneratePathProperty="true" PrivateAssets="Runtime" />
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" GeneratePathProperty="true" Condition="'$(TargetFramework)' != 'net472'" />
</ItemGroup>
+ <!-- Exclude packages that are already inbox in newer .NETCoreApp versions. -->
+ <ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp' or '$(TargetFramework)' == '$(NetCoreAppMinimum)'">
+ <PackageReference Include="Microsoft.Win32.Registry" Version="$(MicrosoftWin32RegistryVersion)" GeneratePathProperty="true" PrivateAssets="Runtime" />
+ <PackageReference Include="System.Security.AccessControl" Version="$(SystemSecurityAccessControlVersion)" GeneratePathProperty="true" PrivateAssets="Runtime" />
+ <PackageReference Include="System.Security.Principal.Windows" Version="$(SystemSecurityPrincipalWindowsVersion)" GeneratePathProperty="true" PrivateAssets="All" />
+ </ItemGroup>
+
<Target Name="CopyFiles" AfterTargets="Build">
<ItemGroup>
<MicrosoftCodeCoverageIO Include="$(PkgMicrosoft_CodeCoverage_IO)\lib\netstandard2.0\**\*" />
@@ -82,10 +86,11 @@
<SystemComponentModelComposition Include="$(PkgSystem_ComponentModel_Composition)\lib\netstandard2.0\**\*" />
<MicrosoftDiagnosticsNETCoreClient Include="$(PkgMicrosoft_Diagnostics_NETCore_Client)\lib\netstandard2.0\**\*" />
<MicrosoftInternalDia Include="$(PkgMicrosoft_Internal_Dia)\tools\net451\**\*" />
- <SystemSecurityAccessControl Include="$(PkgSystem_Security_AccessControl)\runtimes\win\lib\netcoreapp2.0\*" />
- <SystemSecurityPrincipalWindowsUnix Include="$(PkgSystem_Security_Principal_Windows)\runtimes\unix\lib\netcoreapp2.1\*" />
- <SystemSecurityPrincipalWindowsWin Include="$(PkgSystem_Security_Principal_Windows)\runtimes\win\lib\netcoreapp2.1\*" />
- <MicrosoftWin32Registry Include="$(PkgMicrosoft_Win32_Registry)\runtimes\win\lib\netstandard2.0\*" />
+
+ <SystemSecurityAccessControl Include="$(PkgSystem_Security_AccessControl)\runtimes\win\lib\netcoreapp2.0\*" Condition="'$(PkgSystem_Security_AccessControl)' != ''" />
+ <SystemSecurityPrincipalWindowsUnix Include="$(PkgSystem_Security_Principal_Windows)\runtimes\unix\lib\netcoreapp2.1\*" Condition="'$(PkgSystem_Security_Principal_Windows)' != ''" />
+ <SystemSecurityPrincipalWindowsWin Include="$(PkgSystem_Security_Principal_Windows)\runtimes\win\lib\netcoreapp2.1\*" Condition="'$(PkgSystem_Security_Principal_Windows)' != ''" />
+ <MicrosoftWin32Registry Include="$(PkgMicrosoft_Win32_Registry)\runtimes\win\lib\netstandard2.0\*" Condition="'$(PkgMicrosoft_Win32_Registry)' != ''" />
</ItemGroup>
<Copy SourceFiles="@(MicrosoftCodeCoverageIO)" DestinationFiles="$(OutDir)\Microsoft.CodeCoverage.IO\%(RecursiveDir)%(Filename)%(Extension)" Condition="'$(DotNetBuildSourceOnly)' != 'true'" />
@@ -95,10 +100,11 @@
<Copy SourceFiles="@(SystemComponentModelComposition)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" />
<Copy SourceFiles="@(MicrosoftDiagnosticsNETCoreClient)" DestinationFiles="$(OutDir)\Microsoft.Diagnostics.NETCore.Client\%(RecursiveDir)%(Filename)%(Extension)" />
<Copy SourceFiles="@(MicrosoftInternalDia)" DestinationFiles="$(OutDir)\Microsoft.Internal.Dia\%(RecursiveDir)%(Filename)%(Extension)" />
- <Copy SourceFiles="@(SystemSecurityAccessControl)" DestinationFiles="$(OutDir)\runtimes\win\lib\netcoreapp2.0\%(RecursiveDir)%(Filename)%(Extension)" />
- <Copy SourceFiles="@(SystemSecurityPrincipalWindowsUnix)" DestinationFiles="$(OutDir)\runtimes\unix\lib\netcoreapp2.1\%(RecursiveDir)%(Filename)%(Extension)" />
- <Copy SourceFiles="@(SystemSecurityPrincipalWindowsWin)" DestinationFiles="$(OutDir)\runtimes\win\lib\netcoreapp2.1\%(RecursiveDir)%(Filename)%(Extension)" />
- <Copy SourceFiles="@(MicrosoftWin32Registry)" DestinationFiles="$(OutDir)\runtimes\win\lib\netstandard2.0\%(RecursiveDir)%(Filename)%(Extension)" />
+
+ <Copy SourceFiles="@(SystemSecurityAccessControl)" DestinationFiles="$(OutDir)\runtimes\win\lib\netcoreapp2.0\%(RecursiveDir)%(Filename)%(Extension)" Condition="'@(SystemSecurityAccessControl)' != ''" />
+ <Copy SourceFiles="@(SystemSecurityPrincipalWindowsUnix)" DestinationFiles="$(OutDir)\runtimes\unix\lib\netcoreapp2.1\%(RecursiveDir)%(Filename)%(Extension)" Condition="'@(SystemSecurityPrincipalWindowsUnix)' != ''" />
+ <Copy SourceFiles="@(SystemSecurityPrincipalWindowsWin)" DestinationFiles="$(OutDir)\runtimes\win\lib\netcoreapp2.1\%(RecursiveDir)%(Filename)%(Extension)" Condition="'@(SystemSecurityPrincipalWindowsWin)' != ''" />
+ <Copy SourceFiles="@(MicrosoftWin32Registry)" DestinationFiles="$(OutDir)\runtimes\win\lib\netstandard2.0\%(RecursiveDir)%(Filename)%(Extension)" Condition="'@(MicrosoftWin32Registry)' != ''" />
</Target>
</Project>
diff --git a/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj b/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj
index 116098d40..3c2c61a3d 100644
--- a/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj
+++ b/src/package/Microsoft.TestPlatform.Portable/Microsoft.TestPlatform.Portable.csproj
@@ -62,28 +62,34 @@
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="$(MicrosoftExtensionsDependencyModelPackageVersion)" GeneratePathProperty="true"/>
<PackageReference Include="Microsoft.Extensions.FileSystemGlobbing" Version="$(MicrosoftExtensionsFileSystemGlobbingVersion)" GeneratePathProperty="true"/>
<PackageReference Include="Newtonsoft.Json" Version="$(NewtonsoftJsonVersion)" GeneratePathProperty="true"/>
+ <PackageReference Include="Microsoft.Internal.Dia" Version="$(TestPlatformMSDiaVersion)" PrivateAssets="All" GeneratePathProperty="true" />
+ </ItemGroup>
+
+ <!-- Exclude packages that are already inbox in newer .NETCoreApp versions. -->
+ <ItemGroup Condition="'$(TargetFrameworkIdentifier)' != '.NETCoreApp'">
<PackageReference Include="System.Collections.Immutable" Version="$(SystemCollectionsImmutableVersion)" GeneratePathProperty="true"/>
<PackageReference Include="System.Reflection.Metadata" Version="$(SystemReflectionMetadataVersion)" GeneratePathProperty="true"/>
- <PackageReference Include="Microsoft.Internal.Dia" Version="$(TestPlatformMSDiaVersion)" PrivateAssets="All" GeneratePathProperty="true" />
</ItemGroup>
<Target Name="CopyFiles" AfterTargets="Build">
<ItemGroup>
- <MicrosoftCodeCoverageIO Include="$(PkgMicrosoft_CodeCoverage_IO)\lib\netstandard2.0\**\*"></MicrosoftCodeCoverageIO>
- <MicrosoftExtensionsDependencyModel Include="$(PkgMicrosoft_Extensions_DependencyModel)\lib\netstandard2.0\*"></MicrosoftExtensionsDependencyModel>
- <MicrosoftExtensionsFileSystemGlobbing Include="$(PkgMicrosoft_Extensions_FileSystemGlobbing)\lib\netstandard2.0\*"></MicrosoftExtensionsFileSystemGlobbing>
- <NewtonsoftJson Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\*"></NewtonsoftJson>
- <SystemCollectionsImmutable Include="$(PkgSystem_Collections_Immutable)\lib\netstandard2.0\*"></SystemCollectionsImmutable>
- <SystemReflectionMetadata Include="$(PkgSystem_Reflection_Metadata)\lib\netstandard2.0\*"></SystemReflectionMetadata>
- <MicrosoftInternalDia Include="$(PkgMicrosoft_Internal_Dia)\tools\net451\**\*"></MicrosoftInternalDia>
+ <MicrosoftCodeCoverageIO Include="$(PkgMicrosoft_CodeCoverage_IO)\lib\netstandard2.0\**\*" />
+ <MicrosoftExtensionsDependencyModel Include="$(PkgMicrosoft_Extensions_DependencyModel)\lib\netstandard2.0\*" />
+ <MicrosoftExtensionsFileSystemGlobbing Include="$(PkgMicrosoft_Extensions_FileSystemGlobbing)\lib\netstandard2.0\*" />
+ <NewtonsoftJson Include="$(PkgNewtonsoft_Json)\lib\netstandard2.0\*" />
+ <MicrosoftInternalDia Include="$(PkgMicrosoft_Internal_Dia)\tools\net451\**\*" />
+
+ <SystemCollectionsImmutable Include="$(PkgSystem_Collections_Immutable)\lib\netstandard2.0\*" Condition="'$(PkgSystem_Collections_Immutable)' != ''" />
+ <SystemReflectionMetadata Include="$(PkgSystem_Reflection_Metadata)\lib\netstandard2.0\*" Condition="'$(PkgSystem_Reflection_Metadata)' != ''" />
</ItemGroup>
<Copy SourceFiles="@(MicrosoftCodeCoverageIO)" DestinationFiles="$(OutDir)\Microsoft.CodeCoverage.IO\%(RecursiveDir)%(Filename)%(Extension)" />
<Copy SourceFiles="@(MicrosoftExtensionsDependencyModel)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" />
<Copy SourceFiles="@(MicrosoftExtensionsFileSystemGlobbing)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" />
<Copy SourceFiles="@(NewtonsoftJson)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" />
- <Copy SourceFiles="@(SystemCollectionsImmutable)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" />
- <Copy SourceFiles="@(SystemReflectionMetadata)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" />
<Copy SourceFiles="@(MicrosoftInternalDia)" DestinationFiles="$(OutDir)\Microsoft.Internal.Dia\%(RecursiveDir)%(Filename)%(Extension)" />
+
+ <Copy SourceFiles="@(SystemCollectionsImmutable)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" Condition="'@(SystemCollectionsImmutable)' != ''" />
+ <Copy SourceFiles="@(SystemReflectionMetadata)" DestinationFiles="$(OutDir)\%(RecursiveDir)%(Filename)%(Extension)" Condition="'@(SystemReflectionMetadata)' != ''" />
</Target>
</Project>
diff --git a/src/package/Microsoft.TestPlatform.TestHost/Microsoft.TestPlatform.TestHost.csproj b/src/package/Microsoft.TestPlatform.TestHost/Microsoft.TestPlatform.TestHost.csproj
index 356823b26..8fe49c2bf 100644
--- a/src/package/Microsoft.TestPlatform.TestHost/Microsoft.TestPlatform.TestHost.csproj
+++ b/src/package/Microsoft.TestPlatform.TestHost/Microsoft.TestPlatform.TestHost.csproj
@@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
- <TargetFrameworks>netcoreapp3.1;net462</TargetFrameworks>
+ <TargetFrameworks>$(NetCoreAppMinimum);$(NetFrameworkMinimum)</TargetFrameworks>
</PropertyGroup>
<PropertyGroup>
Would you mind if I push into your branch? The changes build fine locally for me (with -sb and without).
Would you mind if I push into your branch? The changes build fine locally for me (with -sb and without).
@ViktorHofer - please feel free to push updates. Thanks for helping.
fails with
Std Error: Error: An assembly specified in the application dependencies manifest (vstest.console.deps.json) was not found: package: 'Microsoft.Win32.Registry', version: '5.0.0' path: 'lib/netstandard2.0/Microsoft.Win32.Registry.dll'
In case you are also looking at this @ViktorHofer :)
Will take a look
I think the condition for .NETCore not including win32.registry libs is the problem, because that library is in-box only in net5.0 and newer. We got approval on dropping netcoreapp3.1 and net5.0 runtimes from our build (we had them because of VS). so I am doing that, that should make this PR easier, or unnecessary.
/azp run microsoft.vstest
Azure Pipelines successfully started running 1 pipeline(s).
Running tests: D:\a_work\1\s\artifacts\bin\Microsoft.TestPlatform.Acceptance.IntegrationTests\Release\net6.0\Microsoft.TestPlatform.Acceptance.IntegrationTests.dll [net6.0|x64]
@nohwnd is it expected that this test library takes 50+ minutes to execute?
It is expected to run for more than 50minutes yes. I also hope we will soon get approval on merging https://github.com/microsoft/vstest/pull/10565 and that should hopefully solve the netstandard1.x deps as well
This can now be closed as vstest removed its out of support TFMs which eliminated the usage of remaining netstandard1.x packages when building source-only.