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

Using Grpc.Tools for .net does not work to compile proto files with number in name #18698

Closed
ach-abe opened this issue Apr 9, 2019 · 3 comments

Comments

@ach-abe
Copy link

ach-abe commented Apr 9, 2019

What version of gRPC and what language are you using?

1.19.0 C#

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

Linux (Debian 9)

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

.NET Core SDK 2.2.101

What did you do?

We have the following message defined in a file named m_double_2d.proto:

syntax = "proto3";

package messages;

message MDouble2D
{
  double x = 1;
  double y = 2;
}

And some more proto files that we need in a project. Using these steps I created the following csproj:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
    <Protobuf_TouchMissingExpected>false</Protobuf_TouchMissingExpected>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Google.Protobuf" Version="3.7.0" />
    <PackageReference Include="Grpc" Version="1.19.0" />
    <PackageReference Include="Grpc.Core" Version="1.19.0" />
    <PackageReference Include="Grpc.Tools" Version="1.19.0">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
    </PackageReference>
  </ItemGroup>

  <ItemGroup>
      <Protobuf Include="../../../messages/*.proto" ProtoRoot="../../../messages/" CompileOutputs="true" GrpcServices="None" />
  </ItemGroup>

</Project>

When I build this on linux using donet build I get errors about MDouble2D not being defined. The errors are from generated .cs files which reference the MDouble2D message. This is weird since the same project build on Windows 10 without issues.

I had a look at the obj/debug/netstandard2.0 folder in the project folder and I noticed that for every compiled proto file there was a corresponding .cs file, except for the generated files for MDouble2D there were 2 .cs files instead of one namely: MDouble2d.cs and MDouble2D.cs. The first file MDouble2d.cs is empty and the other was correctly generated.

I checked the output of dotnet build and I saw the following:

 Protobuf_ReconcileOutputs:
    Creating "obj/Debug/netstandard2.0//MDouble2d.cs" because "AlwaysCreate" was specified.

This file is fed to csc when doing dotnet build instead of the correctly generated MDouble2D.cs, I have the same issue for MDouble3D. It seems that having a number in the filename triggers this issue.

@jtattermusch
Copy link
Contributor

I think this was likely fixed by #18470.
Can you check with v1.20.0-pre2 version of Grpc.Tools (which has the fix) and see if this is still a problem?

@jtattermusch
Copy link
Contributor

I will close for now and reopen if the problem still persists.

@ach-abe
Copy link
Author

ach-abe commented Apr 9, 2019

I think this was likely fixed by #18470.
Can you check with v1.20.0-pre2 version of Grpc.Tools (which has the fix) and see if this is still a problem?

I can confirm that v1.20.0-pre2 solved the issue for me.

@lock lock bot locked as resolved and limited conversation to collaborators Jul 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants