Here is the link to the "home page" for this blog series.

If you prefer to use Visual Studio to create a new project or new to all this .NET Core thing check my post here.

Here I am going to show you how to create a new .NET Core API using .NET Core command-line interface (CLI).

We start with Azure DevOps and create a project called DotNetCore. How to create an Azure DevOps project you can read here. My project will be public, take a look.

Create repo called MyVeryFirstAPIUsingCLI. Get the code by using Visual Studio or your favorite git tool. I prefer to use command line, navigate to your folder where you want to store your code (mine is C:\blog\azureDevOps\DotNetCore) and run git command.

cd \blog\azureDevOps\DotNetCore
git clone https://[email protected]/sergeydotnet/DotNetCore/_git/MyVeryFirstAPIUsingCLI

Create new Solution file(sln)

dotnet new sln

By default the name for sln file will be the same as folder name. The folder name is MyVeryFirstAPIUsingCLI and it looks like this in the file explorer

MyVeryFirstAPIUsingCLI solution file

Now we create new project using template ASP.NET Core Web Application

dotnet new webapi -o MyVeryFirstAPIUsingCLI

This will create a folder called MyVeryFirstAPIUsingCLI and all necessary files. The explanation is here.

Add the project to the solution

 dotnet sln add .\MyVeryFirstAPIUsingCLI\MyVeryFirstAPIUsingCLI.csproj

Push your changes to the Azure DevOps

git add .
git commit -m "Initial commit"
git push

Run the application by navigating to the folder where you have project file *.csproj

In my case

 cd \blog\azureDevOps\DotNetCore\MyVeryFirstAPIUsingCLI\MyVeryFirstAPIUsingCLI

And run dotnet commands, first to restore all NuGet packages, then build the solution and at last run

dotnet restore
dotnet build
dotnet run

Check the ports in the console window

The output looks like this in the browser

Here is the link to the "home page" for this blog series.

Let me know in the comments if you experienced any troubles or if you have any feedbacks. Don't forget to subscribe to get news from Sergey .NET directly to your mailbox.

Get started with .NET Core

Create first .NET Core API

Create a new project Azure DevOps

My public Azure DevOps project