您的问题似乎不完整,您是想询问关于C语言编程的某个具体问题吗?比如C语言的语法、编程技巧、项目开发等。请提供更具体的信息,这样我才能给出更准确的回答。
- 内容介绍
- 文章标签
- 相关推荐
本文共计258个文字,预计阅读时间需要2分钟。
网上教程大多手动通过protoc编译,相对繁琐;给现有工程添加Google.Protobuf和Grpc.Tools的引用(通过NuGet),然后添加proto文件,编辑.csproj文件,设置Project Sdk为Microsoft.NET.Sdk,TargetFramework。
网上的教程大都是手动通过protoc编译, 比较难用
给当前工程添加"Google.Protobuf"和"Grpc.Tools"的引用(通过nuget), 然后添加proto文件, 编辑.csproj文件
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Google.Protobuf" Version="3.11.2" /> <PackageReference Include="Grpc.Tools" Version="2.26.0"> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <PrivateAssets>all</PrivateAssets> </PackageReference> <!--编辑成这样--> <Protobuf Include="*.proto" OutputDir="%(RelativePath)" CompileOutputs="false" GrpcServices="None" /> </ItemGroup> </Project>
然后vs上面编译就会自动生成cs文件
具体可以研究一下:
github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md
总结
以上所述是小编给大家介绍的C# protobuf自动更新cs文件,希望对大家有所帮助!
本文共计258个文字,预计阅读时间需要2分钟。
网上教程大多手动通过protoc编译,相对繁琐;给现有工程添加Google.Protobuf和Grpc.Tools的引用(通过NuGet),然后添加proto文件,编辑.csproj文件,设置Project Sdk为Microsoft.NET.Sdk,TargetFramework。
网上的教程大都是手动通过protoc编译, 比较难用
给当前工程添加"Google.Protobuf"和"Grpc.Tools"的引用(通过nuget), 然后添加proto文件, 编辑.csproj文件
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup> <TargetFramework>netcoreapp3.1</TargetFramework> </PropertyGroup> <ItemGroup> <PackageReference Include="Google.Protobuf" Version="3.11.2" /> <PackageReference Include="Grpc.Tools" Version="2.26.0"> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <PrivateAssets>all</PrivateAssets> </PackageReference> <!--编辑成这样--> <Protobuf Include="*.proto" OutputDir="%(RelativePath)" CompileOutputs="false" GrpcServices="None" /> </ItemGroup> </Project>
然后vs上面编译就会自动生成cs文件
具体可以研究一下:
github.com/grpc/grpc/blob/master/src/csharp/BUILD-INTEGRATION.md
总结
以上所述是小编给大家介绍的C# protobuf自动更新cs文件,希望对大家有所帮助!

