AbpPlugin.Sdk
0.2.1
dotnet add package AbpPlugin.Sdk --version 0.2.1
NuGet\Install-Package AbpPlugin.Sdk -Version 0.2.1
<PackageReference Include="AbpPlugin.Sdk" Version="0.2.1" />
<PackageVersion Include="AbpPlugin.Sdk" Version="0.2.1" />
<PackageReference Include="AbpPlugin.Sdk" />
paket add AbpPlugin.Sdk --version 0.2.1
#r "nuget: AbpPlugin.Sdk, 0.2.1"
#:package AbpPlugin.Sdk@0.2.1
#addin nuget:?package=AbpPlugin.Sdk&version=0.2.1
#tool nuget:?package=AbpPlugin.Sdk&version=0.2.1
AbpPlugin
A plugin host for ABP applications on .NET 10, EF Core and PostgreSQL. It installs signed plugin packages while the application runs, each in an unloadable load context with its own database schema, and upgrades, disables, enables and removes them without a restart.
Preview. 0.x versions may change their API in any minor version (SemVer). Pin an exact version.
Not a Volosoft project. ABP Framework is made and owned by Volosoft. AbpPlugin is an independent enhancement that works on ABP: this repository and its packages don't belong to Volosoft, and aren't affiliated with or endorsed by them.
How it differs from ABP's plug-in modules
ABP's own plug-in modules load module
assemblies from a folder (PlugInSources) when the application starts. They become modules of the application, stay
loaded until it stops, and change only with a restart.
AbpPlugin installs signed packages at run time. Each plugin version loads into a collectible AssemblyLoadContext
with a DI container and a database schema of its own, and is upgraded, disabled (its code unloaded), enabled again and
removed while the application keeps running. A plugin isn't an ABP module: it says what it adds through
IPluginServices, and gets from the host only what the host exposes.
What it does
- Install at run time.
PluginManager.InstallAsynctakes a plugin's folder or zip, checks it, keeps the package in blob storage, migrates the plugin's tables, runs its seeders and starts it. - Each plugin apart. A plugin shares the host's assemblies (ABP, ASP.NET Core, EF Core, Npgsql, the SDK) and loads
the rest privately. Its tables are in a schema of its own (
plg_acme__ratingsforacme.ratings), and its context can't map a table anywhere else. It reads only its own settings, files, secrets and extension points. - Upgrade, disable, enable, remove. An upgrade loads the new version beside the old one, migrates, and swaps it in
one step: calls in flight finish on the old version. Disabling stops new calls, waits for running ones and unloads
the code;
PluginRuntime.GetUnloadReportshows whether it was collected. Removing a plugin keeps its schema and data. - Signed packages. ECDSA P-256 over a digest of every file. A site trusts release keys (from its configuration, or built into the application) and publishers' keys its admins add. A package whose files changed after signing never goes in, and an upgrade must come from the plugin's own signer. Unsigned packages go in only where the server's operator lets admins allow them, and the admins do.
- What a plugin can do with
AbpPlugin.Sdkalone: an EF Core context with migrations, seeders, HTTP endpoints for signed-in callers, public endpoints for webhooks (capped and rate limited), local and distributed event handlers, cron jobs, implementations of the host's extension points, health checks, settings by key, files in blob storage, secrets under Data Protection, and contributions from other plugins' manifests to its own extension points. - One unit of work. A call that may change something (an endpoint other than GET and HEAD, a job, an event handler) runs in one transaction with the server's: what the plugin saves and what the server's services it calls change commit together, or not at all.
- Several servers. Each server brings its plugins in line with the plugins table every 15 seconds. Packages come from blob storage, checked against the hash recorded at install. One server at a time migrates a plugin, and each occurrence of a recurring job runs once for the site.
- Screens of their own. A plugin's browser bundle, a Module Federation remote in its package's
web/, is served from the version installed, and the page gets the enabled plugins' remotes with what the application adds to each (AbpPlugin.Web, docs/web.md). - Seams with defaults for one server: who the caller is, the public endpoints' limits, the application's own checks on a plugin coming in, notices that plugins changed, and recurring jobs' slots. An application with several servers, or rules of its own, registers its own.
Packages
| Package | Holds | Depends on |
|---|---|---|
AbpPlugin |
The host: AbpPluginModule, PluginManager, PluginTrust, PluginRuntime, the endpoint dispatcher, the seams and their defaults, the table mapping |
ABP 10.6 (ASP.NET Core, EF Core on PostgreSQL, blob storing), AbpCluster, Cronos |
AbpPlugin.Web |
Plugins' web parts: AbpPluginWebModule, MapPluginWeb (the files and the remotes list), IPluginWebSections, PluginWebRemotes, MapPluginPartFiles |
AbpPlugin, ASP.NET Core |
@abpjs/plugin-web (npm) |
The page's side: createPluginLoader (registers the remotes, loads what they expose, shares the application's modules), fetchPluginRemotes, and reactPluginComponents in /react |
@module-federation/runtime; React for /react |
AbpPlugin.Sdk |
What a plugin references: PluginEntry, IPluginServices, PluginDbContext, endpoints, events, jobs, settings, files, secrets, health checks, seeders, contributions |
ASP.NET Core, EF Core (relational) |
AbpPlugin.Packaging |
The package format: PluginPackageFormat, PluginSignature, PluginSignatureFile, PluginPackageManifest, SemanticVersion, PluginException, and the signing tool's commands (PluginSigningTool). A marketplace or a build tool can use it |
Plain .NET |
AbpPlugin.Build |
MSBuild targets that pack a plugin after its build, and sign it when given a key | Nothing (targets only) |
AbpPlugin.Sign |
A .NET tool, abp-plugin-sign: keygen, sign, verify, keyid |
AbpPlugin.Packaging |
Getting started
Host plugins in an ABP application:
[DependsOn(typeof(AbpAutofacModule), typeof(AbpBlobStoringFileSystemModule), typeof(AbpPluginModule))]
public class MyHostModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<MyDbContext>(options => options.ReplaceDbContext<IPluginsDbContext>());
Configure<AbpDbContextOptions>(options => options.UseNpgsql());
Configure<AbpBlobStoringOptions>(options => options.Containers.ConfigureDefault(container =>
container.UseFileSystem(fileSystem => fileSystem.BasePath = "/var/lib/my-app/blobs")));
}
public override void OnApplicationInitialization(ApplicationInitializationContext context)
{
IApplicationBuilder app = context.GetApplicationBuilder();
app.UseRouting();
app.UseAuthentication();
app.UseAuthorization();
app.UseEndpoints(endpoints => endpoints.MapPluginEndpoints()); // /api/plugins/{key}/...
}
}
// MyDbContext implements IPluginsDbContext; in its OnModelCreating:
PluginsModel.ConfigurePlugins(modelBuilder);
// In Program.cs, once the application is initialized and its migrations have run:
await app.Services.GetRequiredService<PluginManager>().StartAsync();
Write a plugin on AbpPlugin.Sdk, and pack it with AbpPlugin.Build:
public sealed class HelloPlugin : PluginEntry
{
public override void ConfigureServices(IPluginServices services) => services
.AddEndpoint<Hello>("GET", "hello");
}
public sealed class Hello(PluginContext context, IPluginJson json) : IPluginEndpoint
{
public Task<IResult> HandleAsync(PluginRequest request, CancellationToken cancellationToken) =>
Task.FromResult(json.Result(new { context.Key, context.Version }));
}
Then install its zip with PluginManager.InstallAsync(path), from an admin page of your own.
See hosting, building plugins, the package format,
plugins' web parts, where ABP's layers are and moving an application onto AbpPlugin. Why it is shaped this way is in
ADR 0001. samples/AbpPlugin.SampleHost is a complete host, and
samples/AbpPlugin.Sample a plugin that uses every part of the SDK.
Building
dotnet build AbpPlugin.slnx
The host tests build the sample plugin at two versions, sign it, and run its whole life on the sample host. They need
PostgreSQL on localhost:5432 (postgres/postgres), or the server ABP_PLUGIN_TEST_POSTGRES names, as a user that may
create and drop databases.
dotnet test AbpPlugin.slnx
bash scripts/check-names.sh # no product's name but AbpPlugin's
bash scripts/check-release.sh # the version has its CHANGELOG.md entry
Releasing
Set VersionPrefix and VersionSuffix in Directory.Build.props, move CHANGELOG.md's Unreleased to the version, and
push a tag v<version> (v0.1.0). CI runs the checks, then pushes AbpPlugin, AbpPlugin.Sdk,
AbpPlugin.Packaging, AbpPlugin.Build and AbpPlugin.Sign to nuget.org through Trusted Publishing (the policy
names this repository, ci.yml and the release environment; the repository variable NUGET_USER is the nuget.org
account) and makes a GitHub release.
License
Apache 2.0. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.12)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on AbpPlugin.Sdk:
| Package | Downloads |
|---|---|
|
AbpPlugin
A plugin host for ABP applications: installs signed plugin packages at run time, each in a load context of its own with its own schema, and upgrades, unloads and removes them without a restart. |
GitHub repositories
This package is not used by any popular GitHub repositories.