使用命令行搭建标准AspNetCore项目

使用命令行搭建AspNetCore项目手速度更快一点,而且能够更清楚项目结构以及相互间的引用关系。这里是按照ABP框架推荐的结构来搭建的项目。

搭建好后目录结构为:


image.png
dotnet new sln
dotnet new gitignore
mkdir src
cd src 
dotnet new webapi --name DataTransfer.HttpApi.Host --no-https
dotnet new classlib -f netcoreapp3.1 --name DataTransfer.Application
dotnet new classlib -f netcoreapp3.1 --name DataTransfer.Application.Contracts
dotnet new classlib -f netcoreapp3.1 --name DataTransfer.Domain
dotnet new classlib -f netcoreapp3.1 --name DataTransfer.Domain.Shared
dotnet new classlib -f netcoreapp3.1 --name DataTransfer.EntityFramework
dotnet new classlib -f netcoreapp3.1 --name DataTransfer.EntityFramework.DbMigrations
dotnet new classlib -f netcoreapp3.1 --name DataTransfer.Infrastructure
dotnet sln add src/DataTransfer.HttpApi.Host
dotnet sln add src/DataTransfer.Application
dotnet sln add src/DataTransfer.Application.Contracts
dotnet sln add src/DataTransfer.Domain
dotnet sln add src/DataTransfer.Domain.Shared
dotnet sln add src/DataTransfer.EntityFramework
dotnet sln add src/DataTransfer.EntityFramework.DbMigrations
dotnet sln add src/DataTransfer.Infrastructure

cd src
cd DataTransfer.HttpApi.Host
dotnet add reference ../DataTransfer.Application
dotnet add reference ../DataTransfer.Domain
dotnet add reference ../DataTransfer.EntityFramework
dotnet add reference ../DataTransfer.EntityFramework.DbMigrations

cd ../DataTransfer.Application
dotnet add reference ../DataTransfer.Application.Contracts
dotnet add reference ../DataTransfer.Domain
dotnet add reference ../DataTransfer.EntityFramework

cd ../DataTransfer.Application.Contracts
dotnet add reference ../DataTransfer.Domain
dotnet add reference ../DataTransfer.Domain.Shared

cd ../DataTransfer.Domain
dotnet add reference ../DataTransfer.Domain.Shared

cd ../DataTransfer.EntityFramework
dotnet add reference ../DataTransfer.Domain

cd ../DataTransfer.EntityFramework.DbMigrations
dotnet add reference ../DataTransfer.EntityFramework

你可能感兴趣的:(使用命令行搭建标准AspNetCore项目)