6.9 KiB
Module Installer Projects
Each ABP module includes an .Installer project (e.g., Volo.Abp.Account.Installer) that serves as a Virtual File System container for module installation and resource management. These projects are essential for the ABP CLI to understand and install modules properly.
Purpose of Installer Projects
Installer projects have three main purposes:
- Virtual File System Integration: Register the module's embedded resources with ABP's Virtual File System
- Resource Packaging: Package module metadata files (
.abpmdland.abppkg) as embedded resources - CLI Integration: Enable the ABP CLI to understand module structure and install modules automatically
Structure of Installer Projects
Project Files
{ModuleName}.Installer.csproj: ReferencesVolo.Abp.VirtualFileSystemand embeds module metadata filesInstallationNotes.md: Documentation for the moduleVolo/Abp/{ModuleName}/Abp{ModuleName}InstallerModule.cs: The core module class that registers embedded resources
Example Installer Module
using Volo.Abp.Modularity;
using Volo.Abp.VirtualFileSystem;
namespace Volo.Abp.Account;
[DependsOn(typeof(AbpVirtualFileSystemModule))]
public class AbpAccountInstallerModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpVirtualFileSystemOptions>(options =>
{
options.FileSets.AddEmbedded<AbpAccountInstallerModule>();
});
}
}
Project Configuration
The .csproj file embeds module metadata as content:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
<RootNamespace />
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\framework\src\Volo.Abp.VirtualFileSystem\Volo.Abp.VirtualFileSystem.csproj" />
</ItemGroup>
<ItemGroup>
<!-- Embed module definition file -->
<Content Include="..\..\Volo.Abp.Account.abpmdl">
<Pack>true</Pack>
<PackagePath>content\</PackagePath>
</Content>
<!-- Embed package definition files -->
<Content Include="..\..\**\*.abppkg*">
<Pack>true</Pack>
<PackagePath>content\</PackagePath>
</Content>
</ItemGroup>
</Project>
Module Metadata Files
.abpmdl (Module Definition)
The module definition file describes the module's structure and packages:
{
"folders": {
"items": {
"src": {},
"test": {}
}
},
"packages": {
"Volo.Abp.Account.Web": {
"path": "src/Volo.Abp.Account.Web/Volo.Abp.Account.Web.abppkg",
"folder": "src"
},
"Volo.Abp.Account.Application": {
"path": "src/Volo.Abp.Account.Application/Volo.Abp.Account.Application.abppkg",
"folder": "src"
}
}
}
.abppkg (Package Definition)
Each package has a definition file that specifies its role:
{
"role": "lib.application"
}
Common roles:
lib.application: Application layer packagelib.mvc: MVC/Web layer packagelib.domain: Domain layer packagelib.domain-shared: Shared domain layer packagelib.efcore: Entity Framework Core package
How Installer Projects Work
1. CLI Installation Process
When you run abp add-module Volo.Abp.Account:
- Download Installer Package: CLI downloads
Volo.Abp.Account.Installerfrom NuGet - Read Module Definition: CLI reads the embedded
.abpmdlfile to understand module structure - Read Package Definitions: CLI reads
.abppkgfiles to understand package roles - Install Packages: CLI installs appropriate packages to correct project types based on roles
- Add Dependencies: CLI adds module dependencies to project module classes
2. Virtual File System Integration
The InstallerModule registers itself with the Virtual File System:
options.FileSets.AddEmbedded<AbpAccountInstallerModule>();
This makes embedded resources available at runtime and enables:
- Access to module metadata
- Resource file management
- Module configuration
Creating Installer Projects for New Modules
Required Files
- Project File:
{ModuleName}.Installer.csproj - Module Class:
Abp{ModuleName}InstallerModule.cs - Documentation:
InstallationNotes.md - Module Definition:
{ModuleName}.abpmdl(in module root) - Package Definitions:
{PackageName}.abppkg(in each package)
Template Structure
modules/your-module/
├── src/
│ ├── Volo.Abp.YourModule.Installer/
│ │ ├── Volo.Abp.YourModule.Installer.csproj
│ │ ├── InstallationNotes.md
│ │ └── Volo/
│ │ └── Abp/
│ │ └── YourModule/
│ │ └── AbpYourModuleInstallerModule.cs
│ └── [other packages]/
├── Volo.Abp.YourModule.abpmdl
└── [other module files]
Package Definition Examples
For different package types:
// Application package
{ "role": "lib.application" }
// MVC package
{ "role": "lib.mvc" }
// Domain package
{ "role": "lib.domain" }
// EF Core package
{ "role": "lib.efcore" }
Why Installer Projects Appear "Empty"
Installer projects appear minimal because their primary function is infrastructure, not business logic:
- No Business Logic: Business logic belongs in the actual module packages
- Pure Infrastructure: They only handle module installation and resource management
- CLI Integration: They enable automated module installation through the ABP CLI
- Resource Management: They package and distribute module metadata
Best Practices
- Follow Naming Convention: Use
{ModuleName}.Installerfor the project name - Include Documentation: Always provide
InstallationNotes.mdwith module information - Proper Dependencies: Only depend on
Volo.Abp.VirtualFileSystem - Embed All Metadata: Include both
.abpmdland.abppkgfiles - Test Installation: Verify your installer works with
abp add-modulecommand
Troubleshooting
Common Issues
- Missing .abpmdl file: Ensure the module definition file exists in the module root
- Missing .abppkg files: Each package needs a definition file
- Incorrect roles: Use appropriate roles for each package type
- CLI not finding module: Verify the installer package is published to NuGet
Verification Steps
- Build the installer project:
dotnet build - Check embedded resources: Verify
.abpmdland.abppkgfiles are embedded - Test CLI installation:
abp add-module YourModule - Verify dependencies: Check that module dependencies are added correctly
This installer system enables ABP's sophisticated module architecture, allowing for automated installation with proper dependency resolution and project type matching.