dotnet new classlib
Dotnet core framework'ü ile uygulama geliştirirken çeşitli modüller oluşturur ve geliştireceğimiz ürünü bileşenlerine ayırırız.
Bu ayırma/ayrıştıma işlemini bir nevi katmanlara ayırma işlemini class library dll dosyaları oluşturarak yaparız.
dotnet new classlib --help
Şimdi class library'si oluşturmak için kullanılan komutu --help opsiyonunu kullanarak inceleyelim. Bu komutu kullandığımızda çıktısı aşağıdaki gibi oluşacaktır.
Burada açıklama kısmında .net ve .net standard için class library'si oluşturma projesi şeklinde bir ifade yer almaktadır.
eg@debian:~$ dotnet new classlib --help
Class Library (C#)
Author: Microsoft
Description: A project for creating a class library that targets .NET or .NET Standard
Usage:
dotnet new classlib [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 <choice> The target framework for the project.
Type: choice
net7.0 Target net7.0
netstandard2.1 Target netstandard2.1
netstandard2.0 Target netstandard2.0
net6.0 Target net6.0
Default: net7.0
--langVersion <langVersion> Sets the LangVersion property in the created project file
Type: text
--no-restore If specified, skips the automatic restore of the project on create.
Type: bool
Default: false
To see help for other template languages (F#, VB), use --language option:
dotnet new classlib -h --language F#
dotnet new classlib --name <class_library_name> --output <output_directory>
Burada yine solution oluşturmada kullandığımız opsiyonları kullanacağız. Bunlar --name ve --output olacaktır.
--name opsiyonu ile class library'sine verilecek ismi,
--output opsiyonu ile class library'sinin oluşacağı dizinin yolunu belirtiyoruz.
Aşağıdaki bu opsiyonlar kullanılarak ExampleSolution.ClassLibrary1 isimli bir class library'sinin /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.ClassLibrary1
dizininde oluştuğunu görebilirsiniz.
Bu klasör içerisinde yer alan ExampleSolution.ClassLibrary1.csproj
dosyası projemizin ayarlarının yapıldığı dosyayı ifade ediyor. Her proje şablonu ile oluşturulan projelerde .csproj
uzantılı bu şekilde bir dosya oluşur.
eg@debian:~$ dotnet new classlib --name ExampleSolution.ClassLibrary1 --output /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.ClassLibrary1
The template "Class Library" was created successfully.
Processing post-creation actions...
Restoring /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.ClassLibrary1/ExampleSolution.ClassLibrary1.csproj:
Determining projects to restore...
Restored /home/eg/Data/DotnetCliExamples/ExampleSolution/ExampleSolution.ClassLibrary1/ExampleSolution.ClassLibrary1.csproj (in 38 ms).
Restore succeeded.
Last updated