dotnet new grpc
Dotnet core framework ile gRPC servisleri oluşturabiliyoruz. gRPC kısaca yazıda da belirtildiği gibi, Google’ın geliştirdiği Remote Procedure Call, yani başka bir servis ya da uzak sunucudaki bir metodu sanki kendi servisimizin metoduymuş gibi kullanabilmemizi sağlayan, client-server ilişkisindeki iletişimi kolay ve hızlıca sunan bir frameworktür.
İlk olarak --help opsiyonu ile komutun özelliklerine bakalım.
dotnet new grpc --help
Komutu girdiğimizde karşımıza aşağıdaki gibi bir çıktı geliyor. Şimdi kullanacağımız opsiyonlara bakalım. Bunlar name ve output olacak.
--name opsiyonu ile uygulamaya verilecek ismi,
--output opsiyonu ile projenin oluşacağı dizinin yolunu belirleyebiliyoruz.
eg@debian:~$ dotnet new grpc --help
ASP.NET Core gRPC Service (C#)
Author: Microsoft
Description: A project template for creating a gRPC ASP.NET Core service.
Usage:
dotnet new grpc [options] [template options]
Options:
-n, --name <name> The name for the output being created. If no name is specified, the name of the output
directory is used.
-o, --output <output> Location to place the generated output.
--dry-run Displays a summary of what would happen if the given command line were run if it would
result in a template creation.
--force Forces content to be generated even if it would change existing files.
--no-update-check Disables checking for the template package updates when instantiating a template.
--project <project> The project that should be used for context evaluation.
-lang, --language <C#> Specifies the template language to instantiate.
--type <project> Specifies the template type to instantiate.
Template options:
-F, --Framework <net6.0|net7.0> The target framework for the project.
Type: choice
net7.0 Target net7.0
net6.0 Target net6.0
Default: net7.0
--exclude-launch-settings Whether to exclude launchSettings.json from the generated template.
Type: bool
Default: false
--no-restore If specified, skips the automatic restore of the project on create.
Type: bool
Default: false
--use-program-main Whether to generate an explicit Program class and Main method instead of
top-level statements.
Type: bool
Default: false
dotnet new grpc --name <grpc_app_name> --output <output_directory> <output_directory>
Aşağıdaki çıktıdaki gibi komutu girdiğimizde ExampleSolution.GrpcApp1
adında /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.GrpcApp1
dizininde bir gRPC servisi oluşmuş oluyor.
eg@debian:~$ dotnet new grpc --name ExampleSolution.GrpcApp1 --output /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.GrpcApp1
The template "ASP.NET Core gRPC Service" was created successfully.
Processing post-creation actions...
Restoring /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.GrpcApp1/ExampleSolution.GrpcApp1.csproj:
Determining projects to restore...
Restored /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.GrpcApp1/ExampleSolution.GrpcApp1.csproj (in 5.82 sec).
Restore succeeded.
Last updated