grpc / grpc-dotnet

gRPC for .NET
Apache License 2.0
4.22k stars 777 forks source link

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

Open kzhui125 opened 2 years ago

kzhui125 commented 2 years ago

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
jtattermusch commented 2 years ago

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.

kzhui125 commented 2 years ago

@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 commented 2 years ago

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 ?

jtattermusch commented 2 years ago

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.

kzhui125 commented 2 years ago

@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.

jtattermusch commented 2 years ago

@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.

kzhui125 commented 2 years ago

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:

these packages can leverage the latest platform features.

1

References:

jtattermusch commented 2 years ago

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 commented 2 years ago

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.

JamesNK commented 2 years ago

.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.