Dotnet CLI Komutları
  • Giriş
  • Genel Komutlar
    • dotnet
    • dotnet help
    • dotnet sdk check
  • Yüklü Proje Şablonları ile Proje Oluşturma Komutları
    • dotnet new sln
    • dotnet new classlib
    • dotnet new console
    • dotnet new web
    • dotnet new mvc
    • dotnet new webapi
    • dotnet new react
    • dotnet new angular
    • dotnet new grpc
    • dotnet new nunit
    • dotnet new xunit
    • dotnet new mstest
    • dotnet new gitignore
    • dotnet new globaljson
  • Proje Şablon İşlemleri için Komutlar
    • dotnet new list
    • dotnet new search
    • dotnet new install
    • dotnet new uninstall
    • dotnet new update
  • Proje Genel İşlemler için Komutlar
    • dotnet build
    • dotnet clean
    • dotnet publish
    • dotnet run
  • Çözüm (Solution) İşlemleri için Komutlar
    • dotnet sln add
    • dotnet sln remove
    • dotnet sln list
  • Proje Paket İşlemleri Komutları
    • dotnet add package
    • dotnet remove package
    • dotnet list package
  • Projeler Arası Referans Tanımlama Komutları
    • dotnet add reference
    • dotnet remove reference
    • dotnet list reference
  • Proje Sertifika Komutları
    • dotnet dev-certs https
  • Proje Test Komutları
    • dotnet test
  • Dotnet Araçları Genel Komutları
    • dotnet tool list
    • dotnet tool run
    • dotnet tool search
    • dotnet tool install
    • dotnet tool uninstall
    • dotnet tool update
  • Dotnet Code Generator Komutları
    • dotnet aspnet-codegenerator area
    • dotnet aspnet-codegenerator controller
    • dotnet aspnet-codegenerator view
  • Entity Framework Core Migrasyon Komutları
    • dotnet ef migrations add
    • dotnet ef migrations bundle
    • dotnet ef migrations list
    • dotnet ef migrations remove
    • dotnet ef migrations script
  • Entity Framework Core Veritabanı Komutları
    • dotnet ef database update
    • dotnet ef database drop
  • Entity Framework Core DbContext Komutları
    • dotnet ef dbcontext info
    • dotnet ef dbcontext list
    • dotnet ef dbcontext optimize
    • dotnet ef dbcontext scaffold
    • dotnet ef dbcontext script
Powered by GitBook
On this page
  • dotnet new mvc --help
  • dotnet new mvc --name <mvc_app_name> --output <output_directory> --auth <authentication_type> --no-https --kestrelHttpPort <port_number>
  1. Yüklü Proje Şablonları ile Proje Oluşturma Komutları

dotnet new mvc

Dotnet core framework ile frontend (ön yüz) uygulamaları geliştirmek için bazı şablonlar mevcuttur. Bu şablonlardan ilki olan mvc'yi inceleyelim.

Mvc bir tasarım desenidir. Bu tasarım desenini genellikle web uygulamaları geliştirirken kullanıyoruz. Microsoft front end tarafında uygulama geliştirmek için bu desen üzerine inşa edilmiş bir şablonu bizlere sunuyor.

Bu şablonda (M)odels, (V)iews ve (C)ontrollers adında üç klasör bulunuyor.

  • Models içerisine veri tabanında bulunan tablolarımızı karşılayacak sınıflarımızı,

  • Views içerisine kullanıcıların göreceği cshtml uzantılı, razor sytaxı ile inşa edilen sayfalarımızı,

  • Controllers içerisine ise kullanıcıların yapacağı istekleri karşılayan action metodlarımızı tanımlayabiliyoruz.

Şimdi --help opsiyonu ile komutumuz hakkında bilgi alalım.

dotnet new mvc --help

Komutumuzu girdiğimizde karşımıza aşağıdaki gibi bir çıktı geliyor. Şimdi kullanacağımız opsiyonlara bakalım. Hem şablon opsiyonlarını hem de genel opsiyonlardan bazılarını kullanacağız. Bunlar name, output, auth, no https ve kestrel http port (opsiyon listesinde belirtilmemiş ancak kullanılabiliniyor.) olacak.

--name opsiyonu ile uygulamaya verilecek ismi,

--output opsiyonu ile projenin oluşacağı dizinin yolunu,

--auth opsiyonu ile projede kullanılacak kimlik doğrulama yöntemini,

--no-https ile https protokolünü kullanmayacağımızı,

--kestrelHttpPort ile ise uygulama çalıştığı esnada kullanılacak, varsayılan olarak gelen kestrel sunucusunun http port numarasını belirleyebiliyoruz.

eg@debian:~$ dotnet new mvc --help
ASP.NET Core Web App (Model-View-Controller) (C#)
Author: Microsoft
Description: A project template for creating an ASP.NET Core application with example ASP.NET Core MVC Views and Controllers. This template can also be used for RESTful HTTP services.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/7.0-third-party-notices for details.

Usage:
  dotnet new mvc [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:
  -au, --auth <None|Individual|...>                       The type of authentication to use
                                                          Type: choice
                                                            None           No authentication
                                                            Individual     Individual authentication
                                                            IndividualB2C  Individual authentication with Azure AD 
                                                          B2C
                                                            SingleOrg      Organizational authentication for a 
                                                          single tenant
                                                            MultiOrg       Organizational authentication for 
                                                          multiple tenants
                                                            Windows        Windows authentication
                                                          Default: None
  --aad-b2c-instance <aad-b2c-instance>                   The Azure Active Directory B2C instance to connect to 
                                                          (use with IndividualB2C auth).
                                                          Type: string
                                                          Default: https://login.microsoftonline.com/tfp/
  -ssp, --susi-policy-id <susi-policy-id>                 The sign-in and sign-up policy ID for this project (use 
                                                          with IndividualB2C auth).
                                                          Type: string
                                                          Default: b2c_1_susi
  -S, --SignedOutCallbackPath <SignedOutCallbackPath>     The global signout callback (use with IndividualB2C auth).
                                                          Type: string
                                                          Default: /signout/B2C_1_susi
  -rp, --reset-password-policy-id                         The reset password policy ID for this project (use with 
  <reset-password-policy-id>                              IndividualB2C auth).
                                                          Type: string
                                                          Default: b2c_1_reset
  -ep, --edit-profile-policy-id <edit-profile-policy-id>  The edit profile policy ID for this project (use with 
                                                          IndividualB2C auth).
                                                          Type: string
                                                          Default: b2c_1_edit_profile
  --aad-instance <aad-instance>                           The Azure Active Directory instance to connect to (use 
                                                          with SingleOrg or MultiOrg auth).
                                                          Type: string
                                                          Default: https://login.microsoftonline.com/
  --client-id <client-id>                                 The Client ID for this project (use with IndividualB2C, 
                                                          SingleOrg or MultiOrg auth).
                                                          Type: string
                                                          Default: 11111111-1111-1111-11111111111111111
  --domain <domain>                                       The domain for the directory tenant (use with SingleOrg 
                                                          or IndividualB2C auth).
                                                          Type: string
                                                          Default: qualified.domain.name
  --tenant-id <tenant-id>                                 The TenantId ID of the directory to connect to (use with 
                                                          SingleOrg auth).
                                                          Type: string
                                                          Default: 22222222-2222-2222-2222-222222222222
  --callback-path <callback-path>                         The request path within the application's base path of 
                                                          the redirect URI (use with SingleOrg or IndividualB2C 
                                                          auth).
                                                          Type: string
                                                          Default: /signin-oidc
  -r, --org-read-access                                   Whether or not to allow this application read access to 
                                                          the directory (only applies to SingleOrg or MultiOrg 
                                                          auth).
                                                          Type: bool
                                                          Default: false
  --exclude-launch-settings                               Whether to exclude launchSettings.json from the generated 
                                                          template.
                                                          Type: bool
                                                          Default: false
  --no-https                                              Whether to turn off HTTPS. This option only applies if 
                                                          IndividualB2C, SingleOrg, or MultiOrg aren't used for 
                                                          --auth.
                                                          Type: bool
                                                          Default: false
  -uld, --use-local-db                                    Whether to use LocalDB instead of SQLite. This option 
                                                          only applies if --auth Individual or --auth IndividualB2C 
                                                          is specified.
                                                          Type: bool
                                                          Default: false
  -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
  --no-restore                                            If specified, skips the automatic restore of the project 
                                                          on create.
                                                          Type: bool
                                                          Default: false
  --called-api-url <called-api-url>                       URL of the API to call from the web app. This option only 
                                                          applies if --auth SingleOrg, --auth MultiOrg or --auth 
                                                          IndividualB2C is specified.
                                                          Type: string
                                                          Default: https://graph.microsoft.com/v1.0
  --calls-graph                                           Specifies if the web app calls Microsoft Graph. This 
                                                          option only applies if --auth SingleOrg or --auth 
                                                          MultiOrg is specified.
                                                          Type: bool
                                                          Default: false
  --called-api-scopes <called-api-scopes>                 Scopes to request to call the API from the web app. This 
                                                          option only applies if --auth SingleOrg, --auth MultiOrg 
                                                          or --auth IndividualB2C is specified.
                                                          Type: string
                                                          Default: user.read
  --use-program-main                                      Whether to generate an explicit Program class and Main 
                                                          method instead of top-level statements.
                                                          Type: bool
                                                          Default: false

To see help for other template languages (F#), use --language option:
   dotnet new mvc -h --language F#

dotnet new mvc --name <mvc_app_name> --output <output_directory> --auth <authentication_type> --no-https --kestrelHttpPort <port_number>

Aşağıdaki çıktıdaki gibi komutu girdiğimizde ExampleSolution.Mvc1 adında /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.Mvc1 dizininde bir ASP.NET Core Mvc uygulaması oluşmuş oluyor.

eg@debian:~$ dotnet new mvc --name ExampleSolution.Mvc1 --output /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.Mvc1 --auth None --no-https --kestrelHttpPort 9091
The template "ASP.NET Core Web App (Model-View-Controller)" was created successfully.
This template contains technologies from parties other than Microsoft, see https://aka.ms/aspnetcore/7.0-third-party-notices for details.

Processing post-creation actions...
Restoring /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.Mvc1/ExampleSolution.Mvc1.csproj:
  Determining projects to restore...
  Restored /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.Mvc1/ExampleSolution.Mvc1.csproj (in 43 ms).
Restore succeeded.
Previousdotnet new webNextdotnet new webapi

Last updated 1 year ago