Skip to content

Add gRPC JSON transcoding #40242

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

Merged
merged 11 commits into from
Mar 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
205 changes: 199 additions & 6 deletions AspNetCore.sln

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@
<Import Project="artifacts\bin\GenerateFiles\Directory.Build.props" Condition=" '$(MSBuildProjectName)' != 'GenerateFiles' " />
<Import Project="eng\Dependencies.props" />
<Import Project="eng\ProjectReferences.props" />
<Import Project="eng\RequiresDelayedBuildProjects.props" />
<Import Project="eng\SharedFramework.Local.props" />
<Import Project="eng\SharedFramework.External.props" />
<Import Project="eng\targets\Cpp.Common.props" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'" />
Expand Down
19 changes: 17 additions & 2 deletions eng/Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
<Project>
<Import Project="Common.props" />

<!--
@(RequiresDelayedBuild) projects can be extended many ways but this isn't fully automated because the new
projects likely aren't referenced initially. To add new projects, edit RequiresDelayedBuildProjects.props
manually, update the $(BuildMainlyReferenceProviders)' == 'true' item group near the bottom of this file,
or edit BuildAfterTargetingPack.csproj. Then run GenerateProjectList.ps1 (even for the first option to ensure
the format is correct) and undo any temporary changes. When complete, only BuildAfterTargetingPack.csproj and
other @(RequiresDelayedBuild) projects should mention projects listed in RequiresDelayedBuildProjects.props.
-->
<Import Project="RequiresDelayedBuildProjects.props" />

<!-- These projects are always excluded, even when -projects is specified on command line. -->
<ItemGroup>
<!-- Explicitly excluded projects -->
Expand All @@ -16,8 +26,11 @@
<!-- Exclude the websockets samples for now because they use classic .csproj, which is not yet supported in our build. -->
<ProjectToExclude Include="$(RepoRoot)src\Middleware\WebSockets\samples\**\*.csproj" />

<!-- These projects are meant to be referenced only by tests. -->
<ProjectToExclude Include="$(RepoRoot)src\**\testassets\**\*.*proj"
<!-- These projects are meant to be referenced only by tests or via BuildAfterTargetingPack.csproj. -->
<ProjectToExclude
Include="$(RepoRoot)src\**\testassets\**\*.*proj;
@(RequiresDelayedBuild);
"
Exclude="$(RepoRoot)src\Components\WebAssembly\testassets\WasmLinkerTest\*.*proj;
$(RepoRoot)src\Components\WebView\Samples\PhotinoPlatform\testassets\PhotinoTestApp\*.*proj;
$(RepoRoot)src\Http\Routing\test\testassets\RoutingSandbox\*.*proj;
Expand Down Expand Up @@ -190,6 +203,7 @@
$(RepoRoot)src\ProjectTemplates\*\*.csproj;
$(RepoRoot)src\submodules\spa-templates\src\*.csproj;
$(RepoRoot)src\Extensions\**\*.csproj;
$(RepoRoot)src\BuildAfterTargetingPack\*.csproj;
"
Exclude="
@(ProjectToBuild);
Expand Down Expand Up @@ -229,6 +243,7 @@
$(RepoRoot)src\HealthChecks\**\src\*.csproj;
$(RepoRoot)src\Testing\**\src\*.csproj;
$(RepoRoot)src\Extensions\**\src\*.csproj;
$(RepoRoot)src\BuildAfterTargetingPack\*.csproj;
"
Exclude="
@(ProjectToBuild);
Expand Down
39 changes: 32 additions & 7 deletions eng/CodeGen.proj
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<Project>

<PropertyGroup>
<BuildManaged>true</BuildManaged>
<RepoRoot
Expand All @@ -17,13 +16,15 @@
BuildInParallel="true"
SkipNonexistentTargets="true"
SkipNonexistentProjects="true">
<Output TaskParameter="TargetOutputs" ItemName="_ProjectReferenceProvider" />
<Output TaskParameter="TargetOutputs" ItemName="_ProvidesReferenceOrRequiresDelay" />
</MSBuild>

<ItemGroup>
<_SharedFrameworkAndPackageRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'true')->Distinct())" />
<_SharedFrameworkRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'false')->Distinct())" />
<_TrimmableProject Include="@(_ProjectReferenceProvider->WithMetadataValue('Trimmable', 'true')->Distinct())" />
<_ProjectReferenceProvider Include="@(_ProvidesReferenceOrRequiresDelay->WithMetadataValue('IsProjectReferenceProvider','true')->Distinct())" />
<_RequiresDelayedBuild Include="@(_ProvidesReferenceOrRequiresDelay->WithMetadataValue('RequiresDelayedBuild','true')->Distinct())" />
<_SharedFrameworkAndPackageRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'true'))" />
<_SharedFrameworkRef Include="@(_ProjectReferenceProvider->WithMetadataValue('IsAspNetCoreApp','true')->WithMetadataValue('IsPackable', 'false'))" />
<_TrimmableProject Include="@(_ProjectReferenceProvider->WithMetadataValue('Trimmable', 'true'))" />
</ItemGroup>

<PropertyGroup>
Expand Down Expand Up @@ -57,7 +58,7 @@
This file contains a complete list of the assemblies which are part of the shared framework.
This project is generated using the <IsAspNetCoreApp> and <IsPackable> properties from each .csproj in this repository.
This file is generated using the <IsAspNetCoreApp/> and <IsPackable/> properties from each .csproj in this repository.
-->
<Project>
<ItemGroup>
Expand Down Expand Up @@ -97,6 +98,30 @@

<WriteLinesToFile File="$(TrimmableProjectsList)" Lines="$(TrimmableProjectsListContent)" Overwrite="true" />
<Message Importance="High" Text="Generated $(TrimmableProjectsList)" />
</Target>

<PropertyGroup>
<DelayedBuildFile>$(MSBuildThisFileDirectory)RequiresDelayedBuildProjects.props</DelayedBuildFile>
<DelayedBuildContent><![CDATA[<!--
This file is automatically generated. Run `./eng/scripts/GenerateProjectList.ps1` to update.
This file contains a list of projects that must be restored etc. after App.Ref and App.Runtime are fully built.
This file is generated using <RequiresDelayedBuild/> properties. Content may overlap ProjectReferences.csproj
but that is not required (projects that are not project reference providers are also supported).
-->
<Project>
<ItemGroup>
@(_RequiresDelayedBuild->'<RequiresDelayedBuild Include="%24(RepoRoot)%(ProjectFileRelativePath)" />', '%0A ')
</ItemGroup>
</Project>
]]></DelayedBuildContent>
</PropertyGroup>

<!-- Workaround https://github.com/Microsoft/msbuild/issues/1024 -->
<WriteLinesToFile Condition="'$(OS)' == 'Windows_NT'"
File="$(DelayedBuildFile)" Lines="$([MSBuild]::Escape($(DelayedBuildContent)))" Overwrite="true" />
<Exec Condition="'$(OS)' != 'Windows_NT'"
Command="echo '$(DelayedBuildContent.Replace('\t','\\t'))' > $(DelayedBuildFile)" />
<Message Importance="High" Text="Generated $(DelayedBuildFile)" />
</Target>
</Project>
3 changes: 3 additions & 0 deletions eng/Dependencies.props
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,10 @@ and are generated based on the last package release.
<LatestPackageReference Include="Duende.IdentityServer.EntityFramework.Storage" />
<LatestPackageReference Include="Duende.IdentityServer.Storage" />
<LatestPackageReference Include="FSharp.Core" />
<LatestPackageReference Include="Google.Api.CommonProtos" />
<LatestPackageReference Include="Google.Protobuf" />
<LatestPackageReference Include="Grpc.AspNetCore" />
<LatestPackageReference Include="Grpc.AspNetCore.Server" />
<LatestPackageReference Include="Grpc.Auth" />
<LatestPackageReference Include="Grpc.Net.Client" />
<LatestPackageReference Include="Grpc.Tools" />
Expand All @@ -202,6 +204,7 @@ and are generated based on the last package release.
<LatestPackageReference Include="Serilog.Extensions.Logging" />
<LatestPackageReference Include="Serilog.Sinks.File" />
<LatestPackageReference Include="StackExchange.Redis" />
<LatestPackageReference Include="Swashbuckle.AspNetCore" />
<LatestPackageReference Include="System.Reactive.Linq" />
<LatestPackageReference Include="xunit.abstractions" />
<LatestPackageReference Include="xunit.analyzers" />
Expand Down
2 changes: 2 additions & 0 deletions eng/ProjectReferences.props
Original file line number Diff line number Diff line change
Expand Up @@ -157,5 +157,7 @@
<ProjectReferenceProvider Include="Microsoft.Extensions.Diagnostics.HealthChecks" ProjectPath="$(RepoRoot)src\HealthChecks\HealthChecks\src\Microsoft.Extensions.Diagnostics.HealthChecks.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Testing" ProjectPath="$(RepoRoot)src\Testing\src\Microsoft.AspNetCore.Testing.csproj" />
<ProjectReferenceProvider Include="Microsoft.Extensions.Features" ProjectPath="$(RepoRoot)src\Extensions\Features\src\Microsoft.Extensions.Features.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Grpc.JsonTranscoding" ProjectPath="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.JsonTranscoding\Microsoft.AspNetCore.Grpc.JsonTranscoding.csproj" />
<ProjectReferenceProvider Include="Microsoft.AspNetCore.Grpc.Swagger" ProjectPath="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.Swagger\Microsoft.AspNetCore.Grpc.Swagger.csproj" />
</ItemGroup>
</Project>
20 changes: 20 additions & 0 deletions eng/RequiresDelayedBuildProjects.props
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!--
This file is automatically generated. Run `./eng/scripts/GenerateProjectList.ps1` to update.

This file contains a list of projects that must be restored etc. after App.Ref and App.Runtime are fully built.

This file is generated using <RequiresDelayedBuild/> properties. Content may overlap ProjectReferences.csproj
but that is not required (projects that are not project reference providers are also supported).
-->
<Project>
<ItemGroup>
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\perf\Microsoft.AspNetCore.Grpc.Microbenchmarks\Microsoft.AspNetCore.Grpc.Microbenchmarks.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.JsonTranscoding\Microsoft.AspNetCore.Grpc.JsonTranscoding.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\src\Microsoft.AspNetCore.Grpc.Swagger\Microsoft.AspNetCore.Grpc.Swagger.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\Microsoft.AspNetCore.Grpc.JsonTranscoding.IntegrationTests\Microsoft.AspNetCore.Grpc.JsonTranscoding.IntegrationTests.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests\Microsoft.AspNetCore.Grpc.JsonTranscoding.Tests.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\Microsoft.AspNetCore.Grpc.Swagger.Tests\Microsoft.AspNetCore.Grpc.Swagger.Tests.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\IntegrationTestsWebsite\IntegrationTestsWebsite.csproj" />
<RequiresDelayedBuild Include="$(RepoRoot)src\Grpc\JsonTranscoding\test\testassets\Sandbox\Sandbox.csproj" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion eng/SharedFramework.Local.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
This file contains a complete list of the assemblies which are part of the shared framework.
This project is generated using the <IsAspNetCoreApp> and <IsPackable> properties from each .csproj in this repository.
This file is generated using the <IsAspNetCoreApp/> and <IsPackable/> properties from each .csproj in this repository.
-->
<Project>
<ItemGroup>
Expand Down
12 changes: 7 additions & 5 deletions eng/Versions.props
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,13 @@
<CastleCoreVersion>4.2.1</CastleCoreVersion>
<CommandLineParserVersion>2.3.0</CommandLineParserVersion>
<FSharpCoreVersion>6.0.0</FSharpCoreVersion>
<GoogleProtobufVersion>3.18.0</GoogleProtobufVersion>
<GrpcAspNetCoreVersion>2.40.0</GrpcAspNetCoreVersion>
<GrpcAuthVersion>2.40.0</GrpcAuthVersion>
<GrpcNetClientVersion>2.40.0</GrpcNetClientVersion>
<GrpcToolsVersion>2.40.0</GrpcToolsVersion>
<GoogleApiCommonProtosVersion>2.5.0</GoogleApiCommonProtosVersion>
<GoogleProtobufVersion>3.18.1</GoogleProtobufVersion>
<GrpcAspNetCoreVersion>2.43.0</GrpcAspNetCoreVersion>
<GrpcAspNetCoreServerVersion>2.43.0</GrpcAspNetCoreServerVersion>
<GrpcAuthVersion>2.43.0</GrpcAuthVersion>
<GrpcNetClientVersion>2.43.0</GrpcNetClientVersion>
<GrpcToolsVersion>2.43.0</GrpcToolsVersion>
<DuendeIdentityServerAspNetIdentityVersion>5.2.0</DuendeIdentityServerAspNetIdentityVersion>
<DuendeIdentityServerEntityFrameworkVersion>5.2.0</DuendeIdentityServerEntityFrameworkVersion>
<DuendeIdentityServerVersion>5.2.0</DuendeIdentityServerVersion>
Expand Down
8 changes: 7 additions & 1 deletion eng/targets/ResolveReferences.targets
Original file line number Diff line number Diff line change
Expand Up @@ -311,12 +311,18 @@
<Warning Condition=" '$(IsProjectReferenceProvider)' == 'true' AND '$(AssemblyName)' != '$(MSBuildProjectName)' "
Text="Project name &quot;$(MSBuildProjectName)&quot; is confusing; assembly is named &quot;$(AssemblyName)&quot;." />

<ItemGroup Condition=" '$(IsProjectReferenceProvider)' == 'true' ">
<ItemGroup Condition=" '$(IsProjectReferenceProvider)' == 'true' OR '$(RequiresDelayedBuild)' == 'true' ">
<ProvidesReference Include="$(AssemblyName)">
<IsAspNetCoreApp>$([MSBuild]::ValueOrDefault($(IsAspNetCoreApp),'false'))</IsAspNetCoreApp>
<IsPackable>$([MSBuild]::ValueOrDefault($(IsPackable),'false'))</IsPackable>
<ProjectFileRelativePath>$([MSBuild]::MakeRelative($(RepoRoot), $(MSBuildProjectFullPath)))</ProjectFileRelativePath>
<Trimmable>$([MSBuild]::ValueOrDefault($(Trimmable),'false'))</Trimmable>

<!-- True if the project may be referenced using a @(Reference) item. -->
<IsProjectReferenceProvider>$([MSBuild]::ValueOrDefault($(IsProjectReferenceProvider),'false'))</IsProjectReferenceProvider>

<!-- True if project must be restored etc. after App.Ref and App.Runtime are fully built. -->
<RequiresDelayedBuild>$([MSBuild]::ValueOrDefault($(RequiresDelayedBuild),'false'))</RequiresDelayedBuild>
</ProvidesReference>
</ItemGroup>
</Target>
Expand Down
94 changes: 94 additions & 0 deletions src/BuildAfterTargetingPack/BuildAfterTargetingPack.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<Project>
<!-- Fake a unit test project unless that would prevent building this project. -->
<PropertyGroup>
<IsUnitTestProject Condition=" '$(SkipTestBuild)' != 'true' ">true</IsUnitTestProject>
</PropertyGroup>

<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />

<!--
Forward targets to @(RequiresDelayedBuild) projects after App.Ref has built. Intended for projects that
cannot restore without our App.Ref layout and aren't referenced elsewhere in the repo. For projects
referenced elsewhere, use something else e.g. @(TestAssetProjectReference) items and
FunctionalTestWithAssets.targets for test asset projects that need special handling.
-->
<PropertyGroup>
<TargetFramework>$(DefaultNetCoreTargetFramework)</TargetFramework>

<!-- Nothing from this project ships whether we're faking a unit test project or not. -->
<IsShipping>false</IsShipping>

<!-- Build.props is main thing that references this project. -->
<IsProjectReferenceProvider>false</IsProjectReferenceProvider>
</PropertyGroup>

<ItemGroup>
<!--
When adding new projects to @(RequiresDelayedBuild), temporarily reference the projects here, run
GenerateProjectList.ps1, then undo changes in this file. See comments in Build.props for other options.
-->
<!-- RequiresDelayedBuild Include="..." / -->

<!-- Enforce build order. Need shared Fx before building the important projects. -->
<ProjectReference Include="$(RepoRoot)\src\Framework\App.Ref\src\Microsoft.AspNetCore.App.Ref.csproj"
Private="false"
ReferenceOutputAssembly="false"
SkipGetTargetFrameworkProperties="true" />
</ItemGroup>

<!-- Cannot build in source-build because that does not create an App.Ref layout. -->
<Target Name="BuildDelayedProjects"
BeforeTargets="Build"
Condition=" '$(DotNetBuildFromSource)' != 'true' "
Returns="@(TargetPathWithTargetPlatformMoniker)">
<MSBuild Projects="@(RequiresDelayedBuild)"
BuildInParallel="$(BuildInParallel)"
Properties="MSBuildRestoreSessionId=$([System.Guid]::NewGuid())"
Targets="Restore" />
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Build">
<Output TaskParameter="TargetOutputs" ItemName="TargetPathWithTargetPlatformMoniker" />
</MSBuild>
</Target>

<Target Name="CleanDelayedProjects" BeforeTargets="Clean" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Clean" />
</Target>

<Target Name="CreateHelixPayloadDelayedProjects"
BeforeTargets="CreateHelixPayload"
Condition=" '$(DotNetBuildFromSource)' != 'true' "
Returns="@(HelixWorkItem)">
<MSBuild Projects="@(RequiresDelayedBuild)"
BuildInParallel="$(BuildInParallel)"
SkipNonexistentTargets="true"
Targets="CreateHelixPayload">
<Output TaskParameter="TargetOutputs" ItemName="HelixWorkItem" />
</MSBuild>
</Target>

<Target Name="GetReferencesProvidedDelayedProjects"
BeforeTargets="GetReferencesProvided"
Returns="@(ProvidesReference)">
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="GetReferencesProvided">
<Output TaskParameter="TargetOutputs" ItemName="ProvidesReference" />
</MSBuild>
</Target>

<Target Name="PackDelayedProjects" BeforeTargets="Pack" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Pack" />
</Target>

<Target Name="PublishDelayedProjects" BeforeTargets="Publish" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Publish" />
</Target>

<Target Name="TestDelayedProjects" BeforeTargets="Test" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="Test" />
</Target>

<Target Name="VSTestDelayedProjects" BeforeTargets="VSTest" Condition=" '$(DotNetBuildFromSource)' != 'true' ">
<MSBuild Projects="@(RequiresDelayedBuild)" BuildInParallel="$(BuildInParallel)" Targets="VSTest" />
</Target>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
</Project>
Loading