Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET Framework is prioritized over .NET Standard 2.1 as a target framework. #621

Closed
mayuki opened this issue Feb 2, 2024 · 1 comment · Fixed by #630
Closed

.NET Framework is prioritized over .NET Standard 2.1 as a target framework. #621

mayuki opened this issue Feb 2, 2024 · 1 comment · Fixed by #630

Comments

@mayuki
Copy link
Contributor

mayuki commented Feb 2, 2024

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
@Reag
Copy link

Reag commented Mar 4, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants