Follow the steps below:
- Create an empty project folder called Blog.
- Create a solution inside the project folder.
dotnet new sln
- Create an Api project layer from root folder.
dotnet new webapi -o Blog.Api
- Create a Application project layer from root folder.
dotnet new classlib -o Blog.Application
- Create a Domain project layer from root folder.
dotnet new classlib -o Blog.Domain
- Create an Infrastructure project layer from root folder.
dotnet new classlib -o Blog.Infrastructure
- 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
- 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
- Link the Domain layer to Infrastructure layer.
dotnet add .\Blog.Infrastructure\Blog.Infrastructure.csproj reference .\Blog.Domain\Blog.Domain.csproj
- Link the Infrastructure layer Domain to layer.
dotnet add .\Blog.Domain\Blog.Domain.csproj reference .\Blog.Infrastructure\Blog.Infrastructure.csproj
- Run the project from root project folder.
dotnet run --project .\Blog.Api
- To enable hot reload for development purpose use following command from root project folder.
dotnet watch --project .\Blog.Api run
- Add
.gitignore
file in root project folder.
dotnet new gitignore