This is first post of the series: .NET Microservice with ABP
Posts in the Series
Part 1. Initial Setup (this post)
Part 3. Administration Service
Part 8. Identity server and Angular App
Table of contents
Initial Setup
This is the first step in creating your ABP microservice application. We will create the projects structure and the required projects for your microservice setup.
Most of the architecture is based on the EShopOnAbp Sample microservice application here https://github.com/abpframework/eShopOnAbp.
Startup script
To simplify the project creation I have created a PowerShell script which will create the required projects and folders for use. You can copy and run this file to just create your base projects. The main reason to create this PowerShell script is the get started quickly. Setting up a microservice solution is a time-consuming process this script will not create a working solution. This will only create required projects in the particular structure. I came up with this structure following the EShopOnAbp application. you can update this script with your structure.
You can find the startup script here https://github.com/antosubash/abp-setup/blob/main/init.ps1
1$name = $args[0] 2 3dotnet new web -n "$name.IdentityServer" -o "apps\$name.IdentityServer" 4dotnet new web -n "$name.Gateway" -o "gateway\$name.Gateway" 5dotnet new classlib -n "$name.Shared.Hosting" -o "shared\$name.Shared.Hosting" 6dotnet new console -n "$name.DbMigrator" -o "shared\$name.DbMigrator" 7abp new "$name.AdministrationService" -t module --no-ui -o services\administration 8abp new "$name.IdentityService" -t module --no-ui -o services\identity 9abp new "$name.SaaSService" -t module --no-ui -o services\saas 10dotnet new sln -n "$name" 11dotnet sln ".\$name.sln" add (Get-ChildItem -r **/*.csproj) 12abp new "$name" -t app -u angular -dbms PostgreSQL -m none --separate-identity-server --database-provider ef -csf -o temp 13Move-Item -Path ".\temp\$name\angular\" -Destination .\apps\angular 14Move-Item -Path ".\temp\$name\aspnet-core\src\$name.DbMigrator" -Destination .\shared\ -Force 15Move-Item -Path ".\temp\$name\aspnet-core\src\$name.IdentityServer" -Destination .\apps\ -Force 16Remove-Item -Recurse -Force .\temp\ 17dotnet sln ".\$name.sln" remove (Get-ChildItem -r **/*.Installer.csproj) 18dotnet sln ".\$name.sln" remove (Get-ChildItem -r **/*.Host.Shared.csproj) 19dotnet sln ".\$name.sln" remove (Get-ChildItem -r **/*.MongoDB.csproj) 20dotnet sln ".\$name.sln" remove (Get-ChildItem -r **/*.MongoDB.Tests.csproj) 21dotnet sln ".\$name.sln" remove (Get-ChildItem -r **/*.AdministrationService.IdentityServer.csproj) 22dotnet sln ".\$name.sln" remove (Get-ChildItem -r **/*.IdentityService.IdentityServer.csproj) 23dotnet sln ".\$name.sln" remove (Get-ChildItem -r **/*.SaaSService.IdentityServer.csproj) 24Remove-Item -Recurse -Force (Get-ChildItem -r **/*.SaaSService.IdentityServer) 25Remove-Item -Recurse -Force (Get-ChildItem -r **/*.IdentityService.IdentityServer) 26Remove-Item -Recurse -Force (Get-ChildItem -r **/*.AdministrationService.IdentityServer) 27Remove-Item -Recurse -Force (Get-ChildItem -r **/*.MongoDB.Tests) 28Remove-Item -Recurse -Force (Get-ChildItem -r **/*.MongoDB) 29Remove-Item -Recurse -Force (Get-ChildItem -r **/*.Host.Shared) 30Remove-Item -Recurse -Force (Get-ChildItem -r **/*.Installer) 31abp add-module Volo.AuditLogging -s "services\administration\$name.AdministrationService.sln" --skip-db-migrations 32abp add-module Volo.FeatureManagement -s "services\administration\$name.AdministrationService.sln" --skip-db-migrations 33abp add-module Volo.PermissionManagement -s "services\administration\$name.AdministrationService.sln" --skip-db-migrations 34abp add-module Volo.SettingManagement -s "services\administration\$name.AdministrationService.sln" --skip-db-migrations 35 36abp add-module Volo.Identity -s "services\identity\$name.IdentityService.sln" --skip-db-migrations 37abp add-module Volo.IdentityServer -s "services\identity\$name.IdentityService.sln" --skip-db-migrations 38 39abp add-module Volo.TenantManagement -s "services\saas\$name.SaaSService.sln" --skip-db-migrations
Running the startup script
To run the startup script just create a new powershell script in the location where you want to create the solution and create a file called init.ps1
and copy and past the above mentioned scripts.
To run the script
1.\init.ps1 YourProjectName
This will trigger the scripts and the project creation will start. Wait until the script is done and open the solution to see the created projects.
This script will only create the project and the projects are not ready for running it.
If you want to know more about what the script is doing please check out the video above which will have an explanation of what the script is doing.
Here is the sample repo with the working version of this solution: https://github.com/antosubash/AbpMicroservice