-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
PackageReference broken in WPF projects due to tmp_proj not importing Package-supplied build authoring #810
Comments
Not sure if this is the correct repository to open the issue in, but I can't reproduce the error when using a console app. |
It’s a good idea to open an issue against AspNet as well. |
This looks like an issue with the interaction between gRPC targets and PBT:
It looks like the temp project used for markup compilation doesn't have access to the generated gRPC class from the protobuffer file. From looking at the buildlog, the temp project is building before the gRPC targets have run. I believe you can split the client gRPC portion into a separate project and it will build fine. I did this here and it all built fine. I didn't test anything out at runtime, so you might want to ensure it works. WPF itself doesn't seem to have anything it can do to fix this. I think this is a bug for the gRPC team to ensure their targets are aware of the temp projects used for markup compilation. Of course the above is a simple workaround that should allow you to utilize the types. Let me know if this works for you. |
@rladuca yes, its seems like you can split it into a library project. But isn't it supposed to work directly with .NET Core 3 WPF projects? |
@hayer You're probably correct, and maybe this is actually something WPF is doing incorrectly. This could be related to us not getting NuGet PackageReferences in our temporary markup projects. @ryalanms Do you think this is related to NuGet/Home#5894? It seems like if we ensured that PackageReferences flowed to the temp project, it should get and use all the appropriate targets from gRPC (and other generators) without an issue. |
What seems to be happening is that the WPF MSBuild target is generating a temporary project, like There is also a Guessing the correct solution is to have generated code files passed explicitly into some WPF build target. Still looking into that. |
@hayer Without PackageReferences making it to the temp project, it will never pull in the build targets for gRPC. If we had that working, then gRPC would generate the code files in the temp project's build. WPF temp projects used for markup compilation are basically ignorant of NuGet, seems to be the cause of this and the issue I linked (which is also about missing targets from a PackageReference). @vatsan-madhavan and @ryalanms have, I believe, done some thinking about this in the past. |
@rladuca yes, that's how far I got in my investigation. Was hoping this was something else as the issues linked to earlier seems to have 'stopped'. Guessing this can be closed now? |
@grubioe I'm working on a gRPC e-book for Microsoft Docs and I've run into this issue. Since you've moved it to the |
Yes please, you can document the workaround for 3.0. Thanks! |
@markrendle @grubioe link to the workaround |
FYI I'm experiencing this same issue on .NET Framework 4.7.2 as well. WPF projects create a temporary project that does not include the Protobuf targets in the build. The problem seems to be that Grpc.Tools hooks into Hooking it into |
A potential See comment here: NuGet/Home#5894 (comment). |
If indeed this is the issue that will track NuGet/Home#5894 going forward, please update the title of this issue to match the other one or somehow similarly reflect the general problem instead of its current title which suggests a far more limited scope. |
@kennzhang If you set the |
@davkean |
@clairernovotny Nope, just tried that in PropertyGroup and still doesn't work. Don't understand what @davkean was referring to.. it's WPF. Open new issue? |
@Rand-Random I should clarify, by SDK-project I mean "SDK-projects that use the new WPF SDK". In .NET 5, the WPF SDK is by default if you have UseWpf set to true. The original problem is when you are building for WPF, but implicitly using the WPF support that shipped in .NET Framework. |
@davkean UseWPF is set to true. This is a new dot net 5 project created from scratch. '' |
@davkean
Build still gives the same error.
Edit: |
@kennzhang I don't work on this anymore, however, this bug is tracking an issue with using the SDK format while opt'ing into basically legacy WPF support. The project you have above isn't doing that - if you want see traction on this issue, you would be better approach to file a new bug calling out above with a repro project and/or a build log via |
@davkean |
@kennzhang I forgot to mention, you need to be using at least the latest 5.0.200-preview SDK for that property to work. Can you try with that? |
Just an update that using |
@HEskandari I hope you don't have to target .NET 5 in order to get the fix. I believe the fix is in the SDK. I wonder if you change |
The fix is in the .NET 5 SDK, the targets don't matter. |
I don't get it, people here mentioning that it's been fixed, however I still have the original issue ( Could someone confirm that it's actually been fixed? |
I can confirm that this is still an issue for me as well. I cannot include .proto files in a WPF project. I tried both .NET 5 and 6 with and without IncludePackageReferencesDuringMarkupCompilation and I still get errors. I can manually include the generated .cs files from the obj directory into the project and the build will succeed, but this is an ugly workaround. |
This is in .NET 6.0 and .NET 5.0. Thanks. |
I tested the fix and saw that it works in the 6.0 SDK. But it did not appear to be in 5.0.100. Is it in a later 5.0 version, @ryalanms ? |
@AArnott: .NET 5.0 is still 'opt-in' and requires the property (IncludePackageReferencesDuringMarkupCompilation). Is it not working with the property set? |
Oh, right. I forgot about the opt-in property. :) |
I'm facing this issue on .NET 6 RC1 (Visual Studio 2022 Preview 4).
Repro steps:
var channel = Grpc.Net.Client.GrpcChannel.ForAddress("https://localhost");
var client = new GrpcService2.Greeter.GreeterClient(channel);
Are there any missing steps? |
I wonder if the .proto file is added to the project via contentFiles in the nuget package. I recently encountered this and I wonder if the WPF fix in place accounts for that feature, since it doesn't come in via imported g.props or g.targets files. |
Just came across this today when trying gRpc with WPF for the first time. Didn't know this was an issue; can't believe 2 years later it hasn't been fixed. |
EDIT:
|
So I tried the workaround of creating a DLL with the protos. I found it actually works great. I configure the protos with GrpcServices="Both" and reference it from the server and all clients. It would be simple enough to distribute the DLL as a NuGet package if need be. |
.NET Core Version: 3.0-preview5
Windows version: Windows 10, 1903
Does the bug reproduce also in WPF for .NET Framework 4.8?: No
Problem description:
Trying to use a gRPC service as shown in the AspNetDocs-repo in a WPF app,
<UseWPF>true</UseWPF>
, results in a build error. Visual Studio and VSCode does not report the problem in intellisense but it appears when doing adotnet build .sln
.Actual behavior:
Results in a
When building.
Greet
here is the gRPC service defined in a.proto
file.Expected behavior:
Build & run with no error.
Minimal repro:
I made a repro-repo here.
The text was updated successfully, but these errors were encountered: