grpc-dotnet icon indicating copy to clipboard operation
grpc-dotnet copied to clipboard

Grpc.Core.Api nuget package add .net 5/6 support (seems required for C++/CLI .NET projects)

Open kzhui125 opened this issue 2 years ago • 10 comments

What version of gRPC and what language are you using?

dotnet core

What operating system (Linux, Windows,...) and version?

Windows

What runtime / compiler are you using (e.g. python version or version of gcc)

.net 6

What did you do?

I have a C++ cli dll reference .net 6 dll library. And the .net 6 library references Grpc.AspNetCore(which use Grpc.Core.Api).

Because C++ cli don't support .net standard dlls, it only support .net 5/6 dlls.

So my project can't work.

What did you expect to see?

Please add .net 5/6 support. So my project can work.

1 2

kzhui125 avatar Apr 20 '22 08:04 kzhui125

AFAIK the netstandard 2.x targeted DLLs should be importable by any project that targets net5.0/6.0.

I'm not very familiar with C++/CLI projects, but IIUC the limitation is that the C++/CLI project itself can't target netstandard2.x, not that its dependencies also need to be net5.0/net6.0 (which makes no sense, since netstandard2.x is a strict subset of net5.0).

Closing as there doesn't seem to be a problem with the Grpc.Core.Api package.

jtattermusch avatar Apr 20 '22 10:04 jtattermusch

@jtattermusch yeah you are not familiar with C++/CLI projects.

the limitation is that not only the C++/CLI project itself can't target netstandard2.x, but also its dependencies also need to be net5.0/net6.0

This is a problem with Grpc.Core.Api package. because the package don't give .NET 5/6 target dlls.

kzhui125 avatar Apr 20 '22 11:04 kzhui125

I also don't know why Microsoft not support the pattern "C++/CLI project reference .NET 6 dll which reference .NET Standard 2+ dll".

But this is the fact now, can you reopen this issue @jtattermusch ?

kzhui125 avatar Apr 20 '22 11:04 kzhui125

Reopened, but note that we never tested Grpc.AspNetCore and Grpc.Net.Client with C++/CLI (at least AFAIK), so there's no guarantee things will work even if we made this change. In fact, I'd suggest that you take Grpc.Core.Api sources from the our release branch, try to patch it with the the net5.0 target, and use the locally-built Grpc.Core.Api nuget to test whether things would actually work with C++/CLI (and share your results here). If things work, we can accepting a PR that adds the net50 target, otherwise there would be no point.

jtattermusch avatar Apr 22 '22 10:04 jtattermusch

@jtattermusch It seem to be a Windows bug, after the Windows update my project works:

https://github.com/dotnet/runtime/issues/68261#event-6472857410

But I think .netstandard is obsolete, and net 5/6(latest .net) target support is necessary.

Thanks very much for your support.

kzhui125 avatar Apr 22 '22 11:04 kzhui125

@jtattermusch It seem to be a Windows bug, after the Windows update my project works:

dotnet/runtime#68261 (comment)

But I think .netstandard is obsolete, and net 5/6(latest .net) target support is necessary.

What makes you think netstandard is obsolete?

Thanks very much for your support.

jtattermusch avatar Apr 22 '22 12:04 jtattermusch

Since No new versions of .NET Standard and .NET framework will be released. The word should be "old technology" instead of obsolete (sorry for my vocabulary).

And Microsoft recommends go straight to .NET 6, or multi-target .NET Standard 2.0 and .NET 5+. I think .net Standard is for share code with .NET framework, not for latest features and latest .NET.

for example:

  • nuget Google.Protobuf latest support net5.0 and netstandard2.0 and net45.
  • nuget Grpc.AspNetCore only support net6.0 / net5.0 / netcoreapp3.0

these packages can leverage the latest platform features.

1

References:

  • https://docs.microsoft.com/en-us/dotnet/standard/net-standard?WT.mc_id=dotnet-35129-website&tabs=net-standard-1-0#net-5-and-net-standard
  • https://andrewlock.net/stop-lying-about-netstandard-2-support/
  • https://devblogs.microsoft.com/dotnet/the-future-of-net-standard/

kzhui125 avatar Apr 22 '22 13:04 kzhui125

We might add the net5/net6 target once Grpc.Core.Api is moved over to grpc-dotnet (https://github.com/grpc/grpc-dotnet/pull/1651). Until then, we'd like to prevent any churn that's not absolutely necessary.

jtattermusch avatar Apr 27 '22 13:04 jtattermusch

Grpc.Core.Api has been moved to grpc-dotnet (and it's been deleted from grpc/grpc's master branch) so I'm going to transfer this issue there.

jtattermusch avatar Apr 29 '22 09:04 jtattermusch

.NET Standard isn't obsolete. netstandard20 is the recommended target to use to share a library between .NET Framework and .NET Core/.NET 5+.

Adding a net60 target that's exactly the same as netstandard20 isn't useful. All it will do is increase the size of the nupkg.

JamesNK avatar Apr 29 '22 11:04 JamesNK