Skip to content

Commit

Permalink
Update gRPC start tutorial for VS Mac IDE support (#20294)
Browse files Browse the repository at this point in the history
* Update grpc-start to include VS  Mac IDE support

* Update aspnetcore/tutorials/grpc/grpc-start.md

Co-authored-by: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com>
  • Loading branch information
jongalloway and Rick-Anderson committed Oct 25, 2020
1 parent 7858851 commit 7434412
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
32 changes: 16 additions & 16 deletions aspnetcore/tutorials/grpc/grpc-start.md
Expand Up @@ -36,8 +36,8 @@ In this tutorial, you:

# [Visual Studio for Mac](#tab/visual-studio-mac)

[!INCLUDE[](~/includes/net-core-prereqs-mac-3.1.md)]

* [Visual Studio for Mac version 8.7 or later](/visualstudio/releasenotes/vs2019-mac-relnotes)
* [!INCLUDE [.NET Core 3.1 SDK](~/includes/3.1-SDK.md)]
---

## Create a gRPC service
Expand Down Expand Up @@ -74,19 +74,14 @@ In this tutorial, you:

# [Visual Studio for Mac](#tab/visual-studio-mac)

From a terminal, run the following commands:

```dotnetcli
dotnet new grpc -o GrpcGreeter
cd GrpcGreeter
```

The preceding commands use the [.NET Core CLI](/dotnet/core/tools/dotnet) to create a gRPC service.
* Start Visual Studio for Mac and select **Create a new project**. Alternatively, from the Visual Studio **File** menu, select **New** > **Project**.
* In the **Create a new project** dialog, select **Web and Console** > **App** > **gRPC Service** and select **Next**:

### Open the project

From Visual Studio, select **File** > **Open**, and then select the *GrpcGreeter.csproj* file.
![Create a new project dialog](~/tutorials/grpc/grpc-start/static/cnp-mac.png)

* Select **.NET Core 3.1** for the target framework and click **Next**
* Name the project **GrpcGreeter**. It's important to name the project *GrpcGreeter* so the namespaces will match when you copy and paste code.
* Select **Create**.
---

### Run the service
Expand Down Expand Up @@ -188,9 +183,10 @@ dotnet add GrpcGreeterClient.csproj package Grpc.Tools

# [Visual Studio for Mac](#tab/visual-studio-mac)

* Right-click the **Packages** folder in **Solution Pad** > **Add Packages**
* Right-click **GrpcGreeterClient** project in the **Solution Pad** and select **Manage NuGet Packages**
* Enter **Grpc.Net.Client** in the search box.
* Select the **Grpc.Net.Client** package from the results pane and select **Add Package**
* Click the **Accept** button on the **Accept License** dialog.
* Repeat for `Google.Protobuf` and `Grpc.Tools`.

---
Expand All @@ -217,7 +213,7 @@ dotnet add GrpcGreeterClient.csproj package Grpc.Tools

# [Visual Studio for Mac](#tab/visual-studio-mac)

Right-click the project and select **Tools** > **Edit File**.
Right-click the project and select **Edit Project File**.

---

Expand All @@ -231,7 +227,7 @@ dotnet add GrpcGreeterClient.csproj package Grpc.Tools

### Create the Greeter client

Build the project to create the types in the `GrpcGreeter` namespace. The `GrpcGreeter` types are generated automatically by the build process.
Build the client project to create the types in the `GrpcGreeter` namespace. The `GrpcGreeter` types are generated automatically by the build process.

Update the gRPC client *Program.cs* file with the following code:

Expand Down Expand Up @@ -265,6 +261,10 @@ The Greeter client calls the asynchronous `SayHello` method. The result of the `

# [Visual Studio for Mac](#tab/visual-studio-mac)

* Due to the previously mentioned [HTTP/2 TLS issue on macOS workaround](xref:grpc/troubleshoot#unable-to-start-aspnet-core-grpc-app-on-macos), you'll need to update the channel address in the client to "http://localhost:5000". Update line 13 of **GrpcGreeterClient/Program.cs** to read:
```csharp
using var channel = GrpcChannel.ForAddress("http://localhost:5000");
```
* Start the Greeter service.
* Start the client.

Expand Down
Expand Up @@ -2,7 +2,6 @@
using System;
using System.Net.Http;
using System.Threading.Tasks;
using GrpcGreeter;
using Grpc.Net.Client;

namespace GrpcGreeterClient
Expand Down
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7434412

Please sign in to comment.