Sunday, December 3, 2023

Useful dontet CLI commands for projects

To list available project templates

dotnet new list 




To create a solution

dotnet new sln --name HelloWorld

To create a project

dotnet new console --name HelloWorlddotnet new classlib --name HelloWorldLib

To create a project with Program class (Traditional)

dotnet new console --name HelloWorld --use-program-main true

New project commands will create projects without linking them to solution

To link a project to solution

dotnet sln HelloWorld.sln add HelloWorld\HelloWorld.csproj

or if the folder has one solution and the project folder has only one project

dotnet sln add HelloWorld dotnet sln add HelloWorldLib

To remove a project from solution

dotnet sln remove HelloWorld

To build a solution

dotnet build

To build a specific project

dotnet build HelloWorld\HelloWorld.csproj

or

dotnet build HelloWorld

To run the project

dotnet run --project HelloWorld

or if you are in the project folder itself, you don't have to mention the project

dotnet run --project HelloWorld

No comments:

Post a Comment

Object Oriented Programming- 2- Inheritance

Inheritance is one of the fundamental attributes of object-oriented programming. It allows you to define a child class...