I’m running into a really weird error. My C# classes protoc generation process isn’t working anymore. But it used to works properly, and I’m not sure that I changed anything (I’m fairly certain that it worked great on a build, then the following one crashed)
I’m packaging a simple Nuget Package containing a Protos/
directory with 2 protofiles
.
Using the Nuget Package Explorer
, here is the Package contents:
Now I import the package in a new project, I also import the Grpc tools and I include the 2 Protofiles:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Tests.Tests.TestCodeFirstGrpc" Version="1.0.262" GeneratePathProperty="true" />
<PackageReference Include="Google.Protobuf" Version="3.27.2" />
<PackageReference Include="Grpc.Net.Client" Version="2.64.0" />
<PackageReference Include="Grpc.Tools" Version="2.65.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Protobuf Include="$(PkgTests_Tests_TestCodeFirstGrpc)contentProtos***.proto" GrpcServices="Client" />
</ItemGroup>
</Project>
The files are presents in my project:
But when I run a compilation, it fails with the error : objDebugnet8.0/ : error : No such file or directory
So I made the debugger more verbose, and here is the full logs from the ProtoCompile
task:
Using “ProtoCompile” task from assembly “C:Usersxxx.nugetpackagesgrpc.tools2.65.0build_protobufnet45Protobuf.MSBuild.dll”.
Task “ProtoCompile”
C:Usersxxx.nugetpackagesgrpc.tools2.65.0toolswindows_x64protoc.exe –csharp_out=objDebugnet8.0 –plugin=protoc-gen-grpc=C:Usersxxx.nugetpackagesgrpc.tools2.65.0toolswindows_x64grpc_csharp_plugin.exe –grpc_out=objDebugnet8.0 –grpc_opt=no_server –proto_path=C:Usersxxx.nugetpackagesgrpc.tools2.65.0buildnativeinclude –proto_path=C:Usersxxx.nugetpackagestests.tests.testcodefirstgrpc1.0.262contentProtos –dependency_out=objDebugnet8.089b491885fed334d_GreeterServiceContract.protodep –error_format=msvs C:Usersxxx.nugetpackagestests.tests.testcodefirstgrpc1.0.262contentProtosGreeterServiceContract.proto
objDebugnet8.0/ : error : No such file or directory
The command exited with code 1.
Done executing task “ProtoCompile” — FAILED.
Done building target “_Protobuf_CoreCompile” in project “TestGrpc.csproj” — FAILED.
Here are some solutions I tried before posting:
- The error appeared with an older version of the
Grpc.Tools
library, so I tried to update it to the latest, but nothing changed. The older version used to work before. - I tried to clear the Nuget Cache
- I tried to restart my computer
- I tried to run Visual Studio as an Administrator
- I was not running the latest
Visual Studio Community
version so I updated to the latest (17.10.4) - I tried to recreate a new project from scratch on a newer solution, with the exact same
csproj
, and the error appears too - I tried to recreate manually the
Protos/
dir and manually created the protofiles into it without the import of the nuget, and the Grpc tool is still giving me the same error - I tried to modify the path of the “Include” tag. Putting an incorrect path in the tag results in a successful compilation of the project, without any C# class generated. But when I use the correct path, it fails.
I’m running out of options to try, at this point I just want to completely uninstall the tool in case the issue is coming from it, but I don’t know how to do it.
Can you please help me to resolve this issue?