You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 9, 2021. It is now read-only.
#### Using Visual Studio, Xamarin Studio, or Mondevelop IDEs
63
-
64
-
* The examples are in the directory, `examples/csharp/helloworld`.
41
+
This document will walk you through the "Hello World" example.
42
+
The projects and source files can be found in the `examples/csharp/Helloworld` directory.
65
43
66
44
The example in this walkthrough already adds the necessary
67
45
dependencies for you (Grpc, Grpc.Tools and Google.Protobuf NuGet packages).
68
46
69
47
## Build the example
70
48
71
-
### Using Visual Studio
72
-
* Open the solution `Greeter.sln` with Visual Studio.
73
-
* Build the solution (this will automatically download NuGet dependencies)
74
-
75
-
### Using Xamarin Studio
76
-
* Open the solution `Greeter.sln` with Xamarin Studio.
77
-
* Project->"Restore NuGet Packages"
78
-
* Build the solution (this will automatically download NuGet dependencies)
49
+
### Using Visual Studio (or Visual Studio for Mac)
50
+
* Open the solution `Greeter.sln` with Visual Studio
51
+
* Build the solution
79
52
80
53
### Using .NET Core SDK from the command line
81
-
From the `examples/csharp/helloworld-from-cli` directory:
54
+
From the `examples/csharp/Helloworld` directory:
82
55
83
56
```
84
-
> dotnet restore
85
-
> dotnet build **/project.json
57
+
> dotnet build Greeter.sln
86
58
```
87
59
88
-
### Using the Monodevelop IDE
89
-
Using the Monodevelop IDE, you can build and edit a solution that uses gRPC
90
-
without issues, but unfortunately a workaround is necessary in order to initially restore
91
-
a NuGet dependency on C# gRPC.
60
+
*NOTE: If you want to use gRPC C# from a project that uses the old-style .csproj files (supported by Visual Studio 2013, 2015 and older versions of Mono), please refer to the
61
+
[Greeter using legacy .csproj](https://github.com/grpc/grpc/blob/{{ site.data.config.grpc_release_tag }}/examples/csharp/HelloworldLegacyCsproj/README.md) example.*
92
62
93
-
The problem is that C# gRPC package currently depends on
94
-
System.Interactive.Async 3.0.0, which requires NuGet 2.12+ to install.
95
-
The NuGet included on the latest versions of Monodevelop is too old to install gRPC C#.
96
-
97
-
If you don't want to change the version of NuGet that you're using,
98
-
a possible workaround to get these files is to download the NuGet
99
-
package and unzip without a NuGet client, as follows.
100
-
101
-
* Install NuGet 2.12+ so that it's available from the command line.
102
-
* From the `examples/csharp/helloworld` directory, run `/path/to/nuget restore`.
103
-
* Now that the NuGet dependencies are restored into their proper package folders, build
104
-
the solution from the Monodevelop IDE.
105
-
106
63
## Run a gRPC application
107
64
108
-
### Using Visual Studio, Xamarin Studio, or Monodevelop IDEs
109
-
From the `examples/csharp/helloworld` directory:
110
-
111
-
* Run the server
112
-
113
-
```
114
-
> cd GreeterServer/bin/Debug
115
-
> GreeterServer.exe
116
-
```
117
-
118
-
* In another terminal, run the client
119
-
120
-
```
121
-
> cd GreeterClient/bin/Debug
122
-
> GreeterClient.exe
123
-
```
124
-
125
-
You'll need to run the above executables with "mono" if building on Xamarin Studio for OS X.
126
-
127
-
### Using the .NET Core SDK
65
+
From the `examples/csharp/Helloworld` directory:
128
66
129
67
* Run the server
130
68
131
69
```
132
70
> cd GreeterServer
133
-
> dotnet run
71
+
> dotnet run -f netcoreapp2.1
134
72
```
135
73
136
-
137
74
* In another terminal, run the client
138
75
139
76
```
140
77
> cd GreeterClient
141
-
> dotnet run
78
+
> dotnet run -f netcoreapp2.1
142
79
```
143
80
144
81
Congratulations! You've just run a client-server application with gRPC.
@@ -206,50 +143,26 @@ The `Grpc.Tools` NuGet package contains the protoc and protobuf C# plugin binari
206
143
207
144
### Obtaining the Grpc.Tools NuGet package
208
145
209
-
#### Using Visual Studio
210
-
211
-
This example project already depends on the `Grpc.Tools.{{ site.data.config.grpc_release_tag | remove_first: "v" }}` NuGet package, so it should be included in `examples/csharp/helloworld/packages` when the `Greeter.sln` solution is built from your IDE,
212
-
or when you restore packages via `/path/to/nuget restore` on the command line.
213
-
214
-
#### If you have a NuGet client that is __not__ at version 2.12
215
-
216
-
```
217
-
$ mkdir packages && cd packages
218
-
$ /path/to/nuget install Grpc.Tools
219
-
```
220
-
221
-
#### If you have a NuGet client that is at version 2.12
222
-
223
-
NuGet 2.12 does not install the files from the `Grpc.Tools` package necessary on Linux and OS X.
224
-
Without changing the version of NuGet that you're using, a possible workaround to obtaining the binaries included in the `Grpc.Tools` package
225
-
is by simply downloading the NuGet package and unzipping without a NuGet client, as follows.
$ mkdir -p $temp_dir && cd $temp_dir && curl -sL $curl_url > tmp.zip; unzip tmp.zip && cd .. && cp -r tmp/tools . && rm -rf tmp && cd ../..
232
-
```
146
+
This example project already depends on the `Grpc.Tools.{{ site.data.config.grpc_release_tag | remove_first: "v" }}` NuGet package
147
+
and the package will be downloaded to your local NuGet cache as soon as you restore the nuget packages by clicking "Restore NuGet Packages" in Visual Studio or running `dotnet restore RouteGuide.sln` from the `examples/csharp/RouteGuide` directory.
233
148
234
149
### Commands to generate the gRPC code
235
150
Note that you may have to change the `platform_architecture` directory names (e.g. windows_x86, linux_x64) in the commands below based on your environment.
236
151
237
-
Note that you may also have to change the permissions of the protoc and protobuf
238
-
binaries in the `Grpc.Tools` package under `examples/csharp/helloworld/packages`
0 commit comments