Skip to content

System.Management: deprecated target .netstandard 2.0 #118321

@Yoticc

Description

@Yoticc

I encountered a problem. On my Windows amd64 machine, the DateTime_RoundTrip test failed for the .net481 target.

The first peculiarity I discovered was a condition specified in the test project file:

<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETCoreApp'">
<ProjectReference Include="..\src\System.Management.csproj" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFrameworkIdentifier)' == '.NETFramework'">
<Reference Include="System.Management" />
</ItemGroup>

I replaced there lines with:

<ItemGroup>
  <ProjectReference Include="..\src\System.Management.csproj" />
</ItemGroup>

As before, the project compiled successfully, but the test failed. Either the problem was not related, or there was no related problem.

The next peculiarity was determining which targets were being compiled by examining the source project file:

<TargetFrameworks>$(NetCoreAppCurrent)-windows;$(NetCoreAppCurrent);$(NetCoreAppMinimum)-windows;$(NetCoreAppMinimum);netstandard2.0</TargetFrameworks>

For the main branch, the targets are:
.net10-windows
.net9-windows
.net8-windows
.net10
.net9
.net8
.netstandard2.0
You can also view the condition:

<PropertyGroup>
<TargetPlatformIdentifier>$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)'))</TargetPlatformIdentifier>
<GeneratePlatformNotSupportedAssemblyMessage Condition="'$(TargetPlatformIdentifier)' != 'windows'">SR.PlatformNotSupported_SystemManagement</GeneratePlatformNotSupportedAssemblyMessage>
</PropertyGroup>

According to the MSBuild GetTargetPlatformIdentifier function, the ".netstandard 2.0" identifier is not "-windows." Consequently, we have been unable to generate a valid build for .netstandard or .netframework for some time now, even though these versions are specified in the source and test projects, and we need to support the code for these versions.

Upon reviewing the assembly that was used in testing, it became apparent that it uses the GAC. This means that the tests written for the .netframework were testing the assembly in the GAC, rather than the project code. Without GAC, it would use an empty implementation compiled for .netstandard 2.0 target.

All of this leads me to believe that this is a bug. Either the .netstandard 2.0 target is outdated, in which case it should be removed from the source and tests projects, or it should be made to work.

The Nuget package also does not have a valid .netstandard 2.0 assembly.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions