Develop blog project based on abp vNext and. NET Core - build project with abp cli

Posted by ttroy on Sat, 16 May 2020 07:53:31 +0200

First of all, we have. net core 3.1 development environment by default. If you don't have it, go to download it https://dotnet.microsoft.com/download

Since the project is developed based on abp vNext, it is recommended to go through the official documents of abp before development, https://docs.abp.io/en/abp/latest/

There are many ways to create a project:

  • The first is to manually create a new project using vs
  • The second way is to download directly with the help of abp template http://abp.io/get-started
  • Third, ABP cli (recommended)

abp cli

abp cli is the fastest way to start a new solution using ABP framework, so the premise is that you need to install it.

dotnet tool install -g Volo.Abp.Cli

If your version is low, use the following command to update

dotnet tool update -g Volo.Abp.Cli

For more information, please refer to https://docs.abp.io/en/abp/latest/CLI

abp new

Finally into the theme, use the command

ABP new < solution name > create blog project

By default, two projects will be generated, one aspnet core and one react native. Don't need a project for the time being. Although react native is also very popular, ignore it now.

Then cut all the files in the aspnet core folder to our root directory, and it will look like this.

At this point, the project creation based on abp cli is completed. Open it with VS2019.

At this point, the entire directory structure is like this~

blog_tutorial
 ├── common.props
 ├── Meowv.Blog.sln
 ├── Meowv.Blog.sln.DotSettings
 ├── src
 │   ├── Meowv.Blog.Application
 │   ├── Meowv.Blog.Application.Contracts
 │   ├── Meowv.Blog.DbMigrator
 │   ├── Meowv.Blog.Domain
 │   ├── Meowv.Blog.Domain.Shared
 │   ├── Meowv.Blog.EntityFrameworkCore
 │   ├── Meowv.Blog.EntityFrameworkCore.DbMigrations
 │   ├── Meowv.Blog.HttpApi
 │   ├── Meowv.Blog.HttpApi.Client
 │   └── Meowv.Blog.Web
 └── test
     ├── Meowv.Blog.Application.Tests
     ├── Meowv.Blog.Domain.Tests
     ├── Meowv.Blog.EntityFrameworkCore.Tests
     ├── Meowv.Blog.HttpApi.Client.ConsoleTestApp
     ├── Meowv.Blog.TestBase
     └── Meowv.Blog.Web.Tests

Because it's based on abp development, all default projects help us to reference some very powerful functions that we can't or don't want to use, further optimize the project structure, delete the references we don't want, and beautify.

  • Do you want to kill the test folder first? The project has just been built and tested? Killing doesn't mean testing doesn't matter
  • Kill Meowv.Blog.sln.DotSettings. It's useless at present
  • Added a LICENSE
  • Add another README.md file
  • Add another. github folder. Please ignore it temporarily. This is required by GitHub Action
  • Kill src\Meowv.Blog.DbMigrator, and Meowv.Blog.EntityFrameworkCore.DbMigrations is enough
  • Kill src\Meowv.Blog.HttpApi.Client
  • Add Meowv.Blog.Application.Caching under src directory to handle application service caching
  • Add Meowv.Blog.BackgroundJobs in src directory to handle background timing tasks
  • Add a new project Meowv.Blog.Swagger in src directory, which is used to write Swagger extension, Filter, etc
  • Add the project meowv.blog.toolkit in src directory, where public tool classes and extension methods are placed
  • Change the project name Meowv.Blog.Web to Meowv.Blog.HttpApi.Hosting. In order to be perfect, you can also change the name of the folder
  • Create a new solution folder solution items in the solution, edit the Meowv.Blog.sln file, modify Meowv.Blog.Web to Meowv.Blog.HttpApi.Hosting, and add the following code
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "solution-items", "solution-items", "{731730B9-645C-430A-AB05-3FC2BED63614}"
      ProjectSection(SolutionItems) = preProject
            .gitattributes = .gitattributes
            .gitignore = .gitignore
            common.props = common.props
            LICENSE = LICENSE
            README.md = README.md
      EndProjectSection
EndProject

Now the whole project is like this

blog_tutorial
 ├── common.props
 ├── LICENSE
 ├── Meowv.Blog.sln
 ├── README.md
 └── src
     ├── Meowv.Blog.Application
     ├── Meowv.Blog.Application.Caching
     ├── Meowv.Blog.Application.Contracts
     ├── Meowv.Blog.BackgroundJobs
     ├── Meowv.Blog.Domain
     ├── Meowv.Blog.Domain.Shared
     ├── Meowv.Blog.EntityFrameworkCore
     ├── Meowv.Blog.EntityFrameworkCore.DbMigrations
     ├── Meowv.Blog.HttpApi
     ├── Meowv.Blog.HttpApi.Client
     ├── Meowv.Blog.HttpApi.Hosting
     ├── Meowv.Blog.Swagger
     └── Meowv.Blog.ToolKits

After compiling, all of them are generated successfully. So far, we have successfully built a project of our own with abp cli and adjusted the response.

This chapter only builds the project, which will be broken down one by one later. Do you expect, Sao Nian?

Open source address: https://github.com/Meowv/Blog/tree/blog_tutorial

Topics: github React