runtime icon indicating copy to clipboard operation
runtime copied to clipboard

System.Management: deprecated target .netstandard 2.0

Open 3fbaea00 opened this issue 1 year ago • 7 comments

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: https://github.com/dotnet/runtime/blob/3f25a276772b8d0e54452321e7525b7a176aa4a7/src/libraries/System.Management/tests/System.Management.Tests.csproj#L26-L31

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: https://github.com/dotnet/runtime/blob/3f25a276772b8d0e54452321e7525b7a176aa4a7/src/libraries/System.Management/src/System.Management.csproj#L4

For the main branch, the targets are: .net10-windows .net9-windows .net8-windows .net10 .net9 .net8 .netstandard2.0 You can also view the condition: https://github.com/dotnet/runtime/blob/3f25a276772b8d0e54452321e7525b7a176aa4a7/src/libraries/System.Management/src/System.Management.csproj#L27-L31

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.

3fbaea00 avatar Aug 04 '25 04:08 3fbaea00

Possible related and/or duplicate issue:

  • https://github.com/dotnet/runtime/issues/25284

MihuBot avatar Aug 04 '25 04:08 MihuBot

@ViktorHofer area, I think

3fbaea00 avatar Aug 04 '25 04:08 3fbaea00

Tagging subscribers to this area: @dotnet/area-system-management See info in area-owners.md if you want to be subscribed.

There is no implementation for .NET Standard or .NET Framework for this package from the beginning. The only purpose is to bring in the reference for compilation on .NET Standard.

huoyaoyuan avatar Aug 04 '25 09:08 huoyaoyuan

There is no implementation for .NET Standard or .NET Framework for this package from the beginning. The only purpose is to bring in the reference for compilation on .NET Standard.

I was satisfied with this answer. It sounded very logical. However, two days later, I gave it some more thought. Does this mean that we can no longer add new functionality to the library because the .NET Standard stub requires the GAC to have new methods that it lacks? It seems so.

Why not just use the build from the old branch and remove the .netstandard 2.0 target from main?

3fbaea00 avatar Aug 06 '25 13:08 3fbaea00

Does this mean that we can no longer add new functionality to the library because the .NET Standard stub requires the GAC to have new methods that it lacks? It seems so.

System.Management was archived for a long time. It's totally for compatibility and hasn't ever got new feature on .NET Core. https://github.com/dotnet/runtime/discussions/94552#discussioncomment-7518029

Why not just use the build from the old branch and remove the .netstandard 2.0 target from main?

It complicates the build process.

huoyaoyuan avatar Aug 06 '25 13:08 huoyaoyuan

Thank you for the explanation. Without you, I would not have found the answers. It is strange that such technology has come to be considered outdated and unnecessary when it is used everywhere.

I was initially interested in this module precisely because of the current state of the code.

3fbaea00 avatar Aug 06 '25 14:08 3fbaea00