1.2: Introduction to CLI

Create Project Directory

Navigate to your development folder in your command line and create a folder for the project:

I'll call it EFConnect -- feel free to call it whatever you'd like.

mkdir EFConnect && cd EFConnect

dotnet options

First, let's see what commands we can run with the CLI tool.

dotnet --help

Result:

SDK commands:
  new              Initialize .NET projects.
  restore          Restore dependencies specified in the .NET project.
  run              Compiles and immediately executes a .NET project.
  build            Builds a .NET project.
  publish          Publishes a .NET project for deployment (including the runtime).
  test             Runs unit tests using the test runner specified in the project.
  pack             Creates a NuGet package.
  migrate          Migrates a project.json based project to a msbuild based project.
  clean            Clean build output(s).
  sln              Modify solution (SLN) files.
  add              Add reference to the project.
  remove           Remove reference from the project.
  list             List reference in the project.
  nuget            Provides additional NuGet commands.
  msbuild          Runs Microsoft Build Engine (MSBuild).
  vstest           Runs Microsoft Test Execution Command Line Tool.

We'll use the dotnet new command to create a new project.

dotnet new options

Let's see what options we have.

Result:

These are the templates available when we create a project. It's similar to the GUI project template options when you create a new project in Visual Studio.

There is an Angular template, but we're not going to use it for this project. Feel free to explore it on your own.

We will create an API with the dotnet new webapi command.

First, let's see what options are available to us.

dotnet new webapi options

This outputs a much longer list of options. This is the section we're most interested in:

We'll use the --output option to specify the output directory (otherwise, it will place them directly in our EFConnect folder). We'll also use the --name option to specify the name for our project.

Last updated