jamalkaksouri / Blog.Service.BlogApi

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

.NetCore REST API Development Using Clean Architecture

Project Setup In VSCode

Follow the steps below:

  1. Create an empty project folder called Blog.
  2. Create a solution inside the project folder.
dotnet new sln
  1. Create an Api project layer from root folder.
dotnet new webapi -o Blog.Api
  1. Create a Application project layer from root folder.
dotnet new classlib -o Blog.Application
  1. Create a Domain project layer from root folder.
dotnet new classlib -o Blog.Domain
  1. Create an Infrastructure project layer from root folder.
dotnet new classlib -o Blog.Infrastructure
  1. Add three project layers to Blog.sln from root folder
dotnet sln Blog.sln add .\Blog.Api\Blog.Api.csproj .\Blog.Core\Blog.Core.csproj .\Blog.Infrastructure\Blog.Infrastructure.csproj
  1. Link the Application, Domain and Infrastructure project layers to Api project. If you are in root project folder, use the following command.
dotnet add .\Blog.Api\Blog.Api.csproj reference .\Blog.Application\Blog.Application.csproj .\Blog.Domain\Blog.Domain.csproj .\Blog.Infrastructure\Blog.Infrastructure.csproj
  1. Link the Domain layer to Infrastructure layer.
dotnet add .\Blog.Infrastructure\Blog.Infrastructure.csproj reference .\Blog.Domain\Blog.Domain.csproj
  1. Link the Infrastructure layer Domain to layer.
dotnet add .\Blog.Domain\Blog.Domain.csproj reference .\Blog.Infrastructure\Blog.Infrastructure.csproj
  1. Run the project from root project folder.
dotnet run --project .\Blog.Api
  1. To enable hot reload for development purpose use following command from root project folder.
dotnet watch  --project .\Blog.Api run
  1. Add .gitignore file in root project folder.
dotnet new gitignore

[https://docs.microsoft.com/en-us/dotnet/architecture/microservices/microservice-ddd-cqrs-patterns/microservice-application-layer-implementation-web-api]

About


Languages

Language:C# 99.3%Language:Dockerfile 0.7%