Getting Start to Develop Modules
December 12, 2022 ยท View on GitHub
This article will show you how to develop ABP modules that follow the Module Development Specification document.
Step 1: Generate a new ABP module
Use ABP CLI to generate a new ABP module solution with the name prefix EasyAbp., see: https://docs.abp.io/en/abp/latest/CLI#new.
Step 2: Complete the project structure
-
For each project (except the Web project), create folders according to namespace and move all the original files and folders in, for example:
EasyAbp/(Abp)/MyModuleName/. -
Search
<RootNamespace>EasyAbp.MyModuleName</RootNamespace>in src folder and replace with<RootNamespace />. -
Move all the files in
EasyAbp.MyModuleName.Domain.Shared/EasyAbp/MyModuleName/Localization/MyModuleName/toEasyAbp.MyModuleName.Domain.Shared/EasyAbp/MyModuleName/Localization/. -
Open MyModuleNameDomainSharedModule.cs:
- Change
.AddVirtualJson("/Localization/MyModuleName");to.AddVirtualJson("/EasyAbp/MyModuleName/Localization");. - Change
options.MapCodeNamespace("MyModuleName", typeof(MyModuleNameResource));tooptions.MapCodeNamespace("EasyAbp.MyModuleName", typeof(MyModuleNameResource));.
- Change
-
Open EasyAbp.MyModuleName.Domain.Shared.csproj:
- Change
<EmbeddedResource Include="Localization\MyModuleName\*.json" />to<EmbeddedResource Include="EasyAbp\MyModuleName\Localization\*.json" />. - Change
<Content Remove="Localization\MyModuleName\*.json" />to<Content Remove="EasyAbp\MyModuleName\Localization\*.json" />. - Delete other unused
<EmbeddedResource ... />configurations.
- Change
Step 3: Adjust code of pages
Tip: Skip this step if you do not need Web project.
-
Pages folder should have only MyModuleName subfolder, other folders and files should be in the MyModuleName folder.
-
Open all the index.js for entity management pages:
- Change
abp.localization.getResource('MyProjectName');toabp.localization.getResource('EasyAbpMyProjectName');
- Change
Detail checks
-
Open all the index.js for entity management pages:
- Ensure the param value in
new abp.ModalManager()is correct. - Ensure the param value in
abp.auth.isGranted()is correct.
- Ensure the param value in
-
Open all the index.cshtml for entity management pages:
- Ensure the src value in
<abp-script ... />and<abp-style ... />is correct.
- Ensure the src value in
-
Open MyModuleNameMenuContributor.cs:
- Ensure the url of each menu item is correct.
Step 4: Change and use name constants
-
Open
MyModuleNamePermissions.csand change GroupName toEasyAbp.MyModuleName. -
Open
MyModuleNameSettings.csand change GroupName toEasyAbp.MyModuleName. -
Open
MyModuleNameMenus.csand change Prefix to a public property with the valueEasyAbp.MyModuleName. -
Open
MyModuleNameDbProperties.csand change DbTablePrefix and ConnectionStringName toEasyAbpMyModuleName. -
Open
MyModuleNameRemoteServiceConsts.cs, change RemoteServiceName toEasyAbpMyModuleNameand change ModuleName toeasyAbpMyModuleName. -
Open
MyModuleNameResource.csand replace[LocalizationResourceName("MyModuleName")]with[LocalizationResourceName("EasyAbpMyModuleName")]. -
Open
MyModuleNameController.csand add [Area(MyModuleNameServiceConsts.ModuleName)] attribute.
Step 5: Other adjustments
-
Modify the common.props file according to: https://github.com/EasyAbp/PrivateMessaging/blob/master/common.props.
-
Unified ABP version number.
-
Put ABP version number into the Directory.Build.props file (see demo).
-
Replace
<PackageReference Include="Volo.Abp.xxx" Version="x.x.x" />to<PackageReference Include="Volo.Abp.xxx" Version="$(AbpVersion)" />in all the .csproj files of the solution.