-
Notifications
You must be signed in to change notification settings - Fork 1
Build Pack Install
Ling edited this page Jul 7, 2026
·
5 revisions
本页说明如何构建插件、组织发布包并安装到 PCL。
在插件项目目录运行:
dotnet build .\MyPlugin.csproj --configuration Release --property:Platform=AnyCPU如果项目使用 WPF 或 Windows 目标框架,在非 Windows 环境构建时可能需要:
dotnet build .\MyPlugin.csproj --configuration Release --property:EnableWindowsTargeting=trueJS 插件通常不需要编译。发布时复制:
plugin.json
main.js
lib/
resources/
如果你使用自己的打包器,请确保最终入口脚本仍能被 plugin.json 的 entry 找到。
C# 插件引用 NuGet.org 上的 SDK 包:
<PackageReference Include="PlainCraftLauncher.Plugin.Abstractions" Version="1.1.0" ExcludeAssets="runtime" />包地址:https://www.nuget.org/packages/PlainCraftLauncher.Plugin.Abstractions/1.1.0
推荐每个插件发布为一个 zip:
com.example.myplugin.zip
plugin.json
MyPlugin.dll
DependencyA.dll
Resources/
icon.png
解压后应能直接放到:
PCL/Plugins/com.example.myplugin/
C# 插件发布包不应包含:
PCL.Plugin.Abstractions.dll
原因:宿主和插件必须共享同一个 SDK 契约程序集。如果插件目录里带了自己的副本,CLR 可能把接口视为不同类型,导致宿主无法识别插件入口或注册对象。
安装结构:
PCL/Plugins/<plugin-id>/
plugin.json
入口 DLL 或 main.js
其他依赖文件
示例:
PCL/Plugins/com.example.hello/
plugin.json
HelloPlugin.dll
安装后重启 PCL。
开发时可以用脚本把构建输出复制到插件目录:
$pluginDir = "$env:APPDATA\PCL\Plugins\com.example.hello"
New-Item -ItemType Directory -Force $pluginDir | Out-Null
Copy-Item .\plugin.json $pluginDir -Force
Copy-Item .\bin\Release\net8.0-windows\HelloPlugin.dll $pluginDir -Force实际 PCL 数据目录可能因启动器配置而不同,请以你的测试环境为准。
- 插件版本使用四段式版本号或 SemVer 兼容格式。
- 修改 SDK 能力需求时同步提高
minApiVersion。 - 发布包中附带 changelog。
- 对破坏性变更提高主版本。