.NET Framework is prioritized over .NET Standard 2.1 as a target framework.
mayuki opened this issue · comments
Description
Starting with Unity 2021.2, .NET Standard 2.1 is supported. In those versions, if you set the API Compatibility Level
to .NET Framework
, the target framework selected in the NuGet package will prioritize .NET Framework over .NET Standard 2.1.
For example, if the package includes net462
and netstandard2.1
, and you set the API Compatibility Level
to .NET Framework
in Unity 2021.3, net462
will be chosen.
In the original .NET, this selection would be correct. However, the situation differs in Unity because Unity's .NET Framework includes .NET Standard 2.1. Unity's .NET Framework
represents an API set: .NET Framework 4.x + .NET Standard 2.1
.
https://docs.unity3d.com/2021.3/Documentation/Manual/dotnetProfileSupport.html
In cases where a package includes both net462
and netstandard2.1
, it is usually assumed that the implementation of .NET Standard 2.1
is more modern. When the API Compatibility Level
is set to .NET Standard
, NuGetForUnity selects netstandard2.1
, but when changed to .NET Framework
, the more legacy net462
is selected, leading to potential problems.
This is not just an issue of legacy. While .NET Standard is platform-neutral, .NET Framework targets the Windows platform, which could lead to non-functionality or unnecessary dependencies being installed. Grpc.Net.Client works with netstandard2.1
, but it does not function properly when net462
is selected.
- NuGet Package: Grpc.Net.Client
- NuGetForUnity Version: 4.0.2
- Unity Version: Unity 2022.3
- Operating System: Windows
Id like to +1 this issue. As it stands right now, my automated pipeline cannot function without adding all the NuGet Dlls to my repo manually. This goes directly against the main purpose of NuGet, not having to store all these dependencies in your own source control.
Put simply, this issue is a showstopper for using this tool. As long as its getting net461 versions of libraries that will not compile into unity, I cannot use this for its intended purpose.