MSBuild task that automatically adds nullable reference type annotations to Grpc.Tools-generated C# code.
$ dotnet add package ProtobufNrtAnnotatorAutomatically adds nullable reference type (NRT) annotations to C# code generated by Grpc.Tools, since the upstream protoc compiler does not yet support them.
[!CAUTION] This project is mostly vibe-coded but fully human-reviewed. I wrote this partly to play with Google Antigravity.
Add the package to your project alongside Grpc.Tools and Google.Protobuf:
<ItemGroup>
<PackageReference Include="Google.Protobuf" Version="..." />
<PackageReference Include="Grpc.Tools" Version="..." PrivateAssets="All" />
<PackageReference Include="ProtobufNrtAnnotator" Version="0.4.0">
<IncludeAssets>build</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<Protobuf Include="yourfile.proto" />
</ItemGroup>
The package automatically processes protobuf-generated C# files during build and adds appropriate nullability annotations.
ProtobufNrtAnnotator is an MSBuild task that runs after Grpc.Tools generates C# code from .proto files. It uses Roslyn to:
? annotationsThis ensures your generated protobuf code works seamlessly with C# nullable reference types enabled.
This project uses GitHub Actions to automatically build, test, and publish to NuGet.org. To release a new version:
Bump the version using Cake:
dotnet cake --target=BumpVersion --target-version=0.2.0
This will automatically update Directory.Build.props, Directory.Packages.props, and README.md.
Commit and push the version change:
git commit -am "Bump version to 0.2.0"
git push
Create and push a git tag matching the version:
git tag v0.2.0
git push origin v0.2.0
The GitHub Actions release workflow will automatically: