Remove client from gRPC templates (#9078)

This commit is contained in:
John Luo 2019-04-07 22:42:38 -07:00 committed by GitHub
parent b44680762e
commit 67e08728ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 16 additions and 155 deletions

View File

@ -173,10 +173,9 @@
<BenchmarkDotNetPackageVersion>0.10.13</BenchmarkDotNetPackageVersion>
<CastleCorePackageVersion>4.2.1</CastleCorePackageVersion>
<FSharpCorePackageVersion>4.2.1</FSharpCorePackageVersion>
<GoogleProtobufPackageVersion>3.6.1</GoogleProtobufPackageVersion>
<GoogleProtobufPackageVersion>3.7.0</GoogleProtobufPackageVersion>
<GrpcAspNetCoreServerPackageVersion>0.1.19-pre2</GrpcAspNetCoreServerPackageVersion>
<GrpcCorePackageVersion>1.19.0-pre1</GrpcCorePackageVersion>
<GrpcToolsPackageVersion>1.19.0-pre1</GrpcToolsPackageVersion>
<GrpcToolsPackageVersion>1.20.0-pre1</GrpcToolsPackageVersion>
<IdentityServer4AspNetIdentityPackageVersion>2.3.0</IdentityServer4AspNetIdentityPackageVersion>
<IdentityServer4EntityFrameworkPackageVersion>2.3.0</IdentityServer4EntityFrameworkPackageVersion>
<IdentityServer4PackageVersion>2.3.0</IdentityServer4PackageVersion>

View File

@ -89,7 +89,7 @@ try {
Get-ChildItem "$repoRoot/*.sln" -Recurse `
| ? {
# These .sln files are used by the templating engine.
($_.Name -ne "RazorComponentsWeb-CSharp.sln") -and ($_.Name -ne "GrpcService-CSharp.sln")
($_.Name -ne "RazorComponentsWeb-CSharp.sln")
} `
| % {
Write-Host " Checking $(Split-Path -Leaf $_)"

View File

@ -1,21 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
<ItemGroup>
<Protobuf Include="..\Protos\*.proto" GrpcServices="Client" />
<Content Include="@(Protobuf)" LinkBase="" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.Core" Version="${GrpcCorePackageVersion}" />
<PackageReference Include="Google.Protobuf" Version="${GoogleProtobufPackageVersion}" />
<PackageReference Include="Grpc.Tools" Version="${GrpcToolsPackageVersion}" PrivateAssets="All" />
</ItemGroup>
</Project>

View File

@ -5,8 +5,9 @@
</PropertyGroup>
<ItemGroup>
<Protobuf Include="..\Protos\*.proto" GrpcServices="Server" />
<Content Include="@(Protobuf)" LinkBase="" />
<Protobuf Include="Protos\greet.proto" GrpcServices="Server" Generator="MSBuild:Compile"/>
<Content Include="@(Protobuf)" />
<None Remove="@(Protobuf)" />
</ItemGroup>
<ItemGroup>

View File

@ -14,7 +14,6 @@
<GeneratedContentProperties>
GoogleProtobufPackageVersion=$(GoogleProtobufPackageVersion);
GrpcAspNetCoreServerPackageVersion=$(GrpcAspNetCoreServerPackageVersion);
GrpcCorePackageVersion=$(GrpcCorePackageVersion);
GrpcToolsPackageVersion=$(GrpcToolsPackageVersion);
MicrosoftAspNetCoreMvcRazorRuntimeCompilationPackageVersion=$(MicrosoftAspNetCoreMvcRazorRuntimeCompilationPackageVersion);
MicrosoftEntityFrameworkCoreSqlitePackageVersion=$(MicrosoftEntityFrameworkCoreSqlitePackageVersion);
@ -40,8 +39,7 @@
<ItemGroup>
<GeneratedContent Include="EmptyWeb-CSharp.csproj.in" OutputPath="content/EmptyWeb-CSharp/Company.WebApplication1.csproj" />
<GeneratedContent Include="EmptyWeb-FSharp.fsproj.in" OutputPath="content/EmptyWeb-FSharp/Company.WebApplication1.fsproj" />
<GeneratedContent Include="GrpcService-CSharp.Server.csproj.in" OutputPath="content/GrpcService-CSharp/GrpcService-CSharp.Server/GrpcService-CSharp.Server.csproj" />
<GeneratedContent Include="GrpcService-CSharp.Client.csproj.in" OutputPath="content/GrpcService-CSharp/GrpcService-CSharp.Client/GrpcService-CSharp.Client.csproj" />
<GeneratedContent Include="GrpcService-CSharp.csproj.in" OutputPath="content/GrpcService-CSharp/GrpcService-CSharp.csproj" />
<GeneratedContent Include="RazorComponentsWeb-CSharp.csproj.in" OutputPath="content/RazorComponentsWeb-CSharp/RazorComponentsWeb-CSharp.csproj" />
<GeneratedContent Include="RazorPagesWeb-CSharp.csproj.in" OutputPath="content/RazorPagesWeb-CSharp/Company.WebApplication1.csproj" />
<GeneratedContent Include="RazorClassLibrary-CSharp.csproj.in" OutputPath="content/RazorClassLibrary-CSharp/Company.RazorClassLibrary1.csproj" />

View File

@ -18,24 +18,13 @@
},
"sourceName": "GrpcService-CSharp",
"preferNameDirectory": true,
"guids": [
"4C26868E-5E7C-458D-82E3-040509D0C71F",
"5990939C-7E7B-4CFA-86FF-44CA5756498A",
"650B3CE7-2E93-4CC4-9F46-466686815EAA"
],
"sources": [
{
"modifiers": [
{
"condition": "(ExcludeLaunchSettings)",
"exclude": [
"GrpcService-CSharp.Server/Properties/launchSettings.json"
]
},
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"exclude": [
"GrpcService-CSharp.sln"
"Properties/launchSettings.json"
]
}
]
@ -73,16 +62,7 @@
},
"primaryOutputs": [
{
"condition": "(HostIdentifier == \"dotnetcli\" || HostIdentifier == \"dotnetcli-preview\")",
"path": "GrpcService-CSharp.sln"
},
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"path": "GrpcService-CSharp.Server/GrpcService-CSharp.Server.csproj"
},
{
"condition": "(HostIdentifier != \"dotnetcli\" && HostIdentifier != \"dotnetcli-preview\")",
"path": "GrpcService-CSharp.Client/GrpcService-CSharp.Client.csproj"
"path": "GrpcService-CSharp.csproj"
}
],
"defaultName": "GrpcService-CSharp1",

View File

@ -1,30 +0,0 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Greet;
using Grpc.Core;
namespace GrpcService_CSharp
{
public class Program
{
static async Task Main(string[] args)
{
// Include port of the gRPC server as an application argument
var port = args.Length > 0 ? args[0] : "50051";
var channel = new Channel("localhost:" + port, ChannelCredentials.Insecure);
var client = new Greeter.GreeterClient(channel);
var reply = await client.SayHelloAsync(new HelloRequest { Name = "GreeterClient" });
Console.WriteLine("Greeting: " + reply.Message);
await channel.ShutdownAsync();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}

View File

@ -1,50 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.27130.2027
MinimumVisualStudioVersion = 15.0.26124.0
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GrpcService-CSharp.Server", "GrpcService-CSharp.Server\GrpcService-CSharp.Server.csproj", "{650B3CE7-2E93-4CC4-9F46-466686815EAA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GrpcService-CSharp.Client", "GrpcService-CSharp.Client\GrpcService-CSharp.Client.csproj", "{5990939C-7E7B-4CFA-86FF-44CA5756498A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Debug|x64.ActiveCfg = Debug|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Debug|x64.Build.0 = Debug|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Debug|x86.ActiveCfg = Debug|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Debug|x86.Build.0 = Debug|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Release|Any CPU.Build.0 = Release|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Release|x64.ActiveCfg = Release|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Release|x64.Build.0 = Release|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Release|x86.ActiveCfg = Release|Any CPU
{5990939C-7E7B-4CFA-86FF-44CA5756498A}.Release|x86.Build.0 = Release|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Debug|x64.ActiveCfg = Debug|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Debug|x64.Build.0 = Debug|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Debug|x86.ActiveCfg = Debug|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Debug|x86.Build.0 = Debug|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|Any CPU.Build.0 = Release|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x64.ActiveCfg = Release|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x64.Build.0 = Release|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x86.ActiveCfg = Release|Any CPU
{650B3CE7-2E93-4CC4-9F46-466686815EAA}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4C26868E-5E7C-458D-82E3-040509D0C71F}
EndGlobalSection
EndGlobal

View File

@ -30,6 +30,8 @@ namespace GrpcService_CSharp
app.UseEndpoints(endpoints =>
{
// Communication with gRPC endpoints must be made through a gRPC client.
// To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909
endpoints.MapGrpcService<GreeterService>();
});
}

View File

@ -21,7 +21,7 @@ namespace Templates.Test
public ProjectFactoryFixture ProjectFactory { get; }
public ITestOutputHelper Output { get; }
[Fact(Skip = "https://github.com/aspnet/AspNetCore/issues/7973")]
[Fact]
public async Task GrpcTemplate()
{
Project = await ProjectFactory.GetOrCreateProject("grpc", Output);
@ -35,36 +35,18 @@ namespace Templates.Test
var buildResult = await Project.RunDotNetBuildAsync();
Assert.True(0 == buildResult.ExitCode, ErrorMessages.GetFailedProcessMessage("build", Project, buildResult));
using (var serverProcess = Project.StartBuiltServerAsync())
using (var serverProcess = Project.StartBuiltProjectAsync())
{
Assert.False(
serverProcess.Process.HasExited,
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built server", Project, serverProcess.Process));
using (var clientProcess = Project.StartBuiltClientAsync(serverProcess))
{
// Wait for the client to do its thing
await Task.Delay(100);
Assert.False(
clientProcess.Process.HasExited,
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built client", Project, clientProcess.Process));
}
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built service", Project, serverProcess.Process));
}
using (var aspNetProcess = Project.StartPublishedServerAsync())
using (var aspNetProcess = Project.StartPublishedProjectAsync())
{
Assert.False(
aspNetProcess.Process.HasExited,
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published server", Project, aspNetProcess.Process));
using (var clientProcess = Project.StartPublishedClientAsync())
{
// Wait for the client to do its thing
await Task.Delay(100);
Assert.False(
clientProcess.Process.HasExited,
ErrorMessages.GetFailedProcessMessageOrEmpty("Run built client", Project, clientProcess.Process));
}
ErrorMessages.GetFailedProcessMessageOrEmpty("Run published service", Project, aspNetProcess.Process));
}
}
}