[release/8.0] Fix auto import of proto files when gRPC JSON transcoding is a transitive reference #52470
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Backport of #52443 to release/8.0
/cc @JamesNK
Fix auto import of proto files when gRPC JSON transcoding is a transitive reference
gRPC JSON transcoding needs a proto file to be an app's source code directory. In .NET 7, the file had to be manually downloaded and copied to the right location. .NET 8 introduces a Cool Trick to bundle proto files in the package and automatically include them in the proto compilation. This uses msbuild that is shipped with in the nuget package.
The documentation relies on people enabling this feature: https://learn.microsoft.com/en-us/aspnet/core/grpc/json-transcoding?view=aspnetcore-8.0#usage
The msbuild file is in the package's
/build
directory, which means it doesn't run when Microsoft.AspNetCore.Grpc.JsonTranscoding is transitively referenced by the web app. e.g. app -> CustomLibrary -> Microsoft.AspNetCore.Grpc.JsonTranscoding.The fix is to also put the msbuild file in
/buildTransitive
.Customer Impact
If Microsoft.AspNetCore.Grpc.JsonTranscoding is transitively referenced by a developer's app then the app will fail to compile.
The work around is to add a direct reference to Microsoft.AspNetCore.Grpc.JsonTranscoding. However, because including the proto file happens behind the scenes, it will be very difficult for a developer to figure out what has gone wrong and how to fix it.
Regression?
[If yes, specify the version the behavior has regressed from]
Risk
This is a minor change is to the Microsoft.AspNetCore.Grpc.JsonTranscoding package. Nothing else in .NET depends on it, and the feature that is impacted is opt-in (requires an msbuild property to enable).
Verification
Before:

After:

Packaging changes reviewed?
When servicing release/2.1