Creating a project using the command line .Net

Creating a project using the command line .Net

please find the following steps need to follow to create a solution file

To Create a Blank solution

  1. create a new folder (mkdir solution folder name)

    mkdir ProjectA

  2. Create a empty solution usin command dotnet new sln --name

    dotnet new sln --name ProjectA

To know the list of projects you can create

please use the below command and press enter.

dotnet new

Example

template.PNG

To know the list of frameworks installed for a particular project

please find the command below

dotnet new <project name> -h

Example

dotnet new nunit -h

image.png

To Create Project using a specific project and using a specific project framework.

1 - we need to create a new project using command

  ```dotnet new  <projectname> -f <framework> --output <folder project> ```

Example

command

dotnet new nunit -f net5.0 --output Source/ProjectA.Test

2 - To add this project to the existing Solution

dotnet sln add --in-root <project path> 'in-root' wont create any solution folders

dotnet sln add --in-root source/ProjectA.Test

dotnet sln add -s '<specify the solution folder>' <project path> '-s' create solution folder

dotnet sln add source/ProjectA.Test -s Application

To Add references to an existing project.

1 - Add a single project reference

for instance if we had two projects A is a source project and project B is a reference project

dotnet add SourceProject reference Destination Project

dotnet add A reference B

2 - Multiple project reference

for instance if we had two projects A is a source project and project B and C is a reference project

dotnet add SourceProject reference Destination Project1 Destination Project2

dotnet add A reference B C

Sample project