Grpc.Tools package has MSBuild/XBuild magic to generate C# source code#6062
Grpc.Tools package has MSBuild/XBuild magic to generate C# source code#6062aniongithub wants to merge 3 commits intogrpc:masterfrom
Conversation
…ge that includes a "Proto" item type. This automatically builds ProtoBuf and Grpc Sharp wrappers for files that specify this item type and includes the generated C# in the project. Tested on Windows (Visual Studio 2013) and OSX (Xamarin Studio)
Fix a warning from the C# compiler for duplicate cs files included at the compile step
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
Can one of the admins verify this patch? |
3 similar comments
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
|
Can one of the admins verify this patch? |
…nly files that exist (are touchable) make their way into the Compile target.
|
CLAs look good, thanks! |
| { | ||
| try | ||
| { | ||
| var projectDir = args[0]; |
There was a problem hiding this comment.
The platform detection code already exists in Grpc.Core.Internal.PlatformApis, having a slightly different version of the same code here feels odd. On the other hand, we can't really make code generator project depend on Grpc.Core. Anyway, I feel like a cleaner solution is needed here.
There was a problem hiding this comment.
I think it might be ok to have this depend on Grpc.Core - because this is a build time only dependency. Unfortunately this class is internal so I can't use it as-is. Would you feel better if I used some other nuget package that included this check? Again, note that this a build-time dependency only.
There was a problem hiding this comment.
At this point you can probably just copy-and-paste the PlatformApi class and add a big comment that this is actually what Grpc.Core already implements. Then we are at least duplicating the very same code and we can figure out the rest in the next step.
|
this is ok to test |
|
I generally like the idea of this contribution - thanks for the pull request. There's a couple of problems though: Btw, we already have some related issues: #4805 and protocolbuffers/protobuf#1193. It is probably worth reading through, as it identifies some of the challenges. Also, CC @jskeet. |
|
Closing this pull request. Will reopen with separate Nuget package called Grpc.Tools.MSBuildIntegration that addresses many of the features requested on this thread. |
|
However, the #6085 died. Do you have any plan to continue the project or add more advanced support to MSBuild? |
|
We might revisit that at some point, but for now, we have no plans to work on that for the next few quarters. Contributions are welcome though (but please be aware that this is a tricky problem to solve and it needs to support more than just trivial .proto files - see previous discussion). |
The changes in this pull request contain changes that enable users to automagically generate C# source code for .proto files included in their project.
All they have to do is install the Nuget package (and possibly reload their solution). Now the "Build Action" for proto files will contain a new item called "Proto". If selected, these files generate C# in the obj/$(Configuration) folder and include them as part of the build.
This should be completely cross-platform, I've tested it on Windows + VS2013 and OSX + Xamarin Studio.
@jtattermusch, this was the reason I wanted binaries for all platforms in this nuget package. Thanks for helping with that request!