Skip to content

Commit 2bcc2c7

Browse files
committed
feat: add module packaging and CLI tool
- Add nuke pack-module target for creating .modpkg packages - Add Modulus.Cli project with install/uninstall/list commands - Add host version compatibility validation - Reorganize artifacts directory structure: - bin/ for host apps and shared assemblies - bin/Modules/ for module compilation output - cli/ for CLI tool - packages/ for CLI NuGet packages - ModulesInstaller/ for .modpkg files - tests/ for test assemblies - Archive add-module-packaging change
1 parent 29f357b commit 2bcc2c7

File tree

51 files changed

+2040
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2040
-47
lines changed

.cursor/rules/assembly-domain-rules.mdc

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,33 +26,51 @@ The Modulus framework uses `AssemblyLoadContext` for module isolation. Every pro
2626
2. **Add `<ModulusAssemblyDomain>` and output path** to your `.csproj`:
2727

2828
```xml
29-
<!-- For shared assemblies -->
29+
<!-- For shared assemblies (Host, Core, SDK, UI libraries) -->
3030
<PropertyGroup>
3131
<ModulusAssemblyDomain>Shared</ModulusAssemblyDomain>
32-
<OutputPath>..\..\artifacts\</OutputPath>
32+
<OutputPath>..\..\artifacts\bin\</OutputPath>
3333
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
3434
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
3535
</PropertyGroup>
3636

3737
<!-- For module assemblies -->
3838
<PropertyGroup>
3939
<ModulusAssemblyDomain>Module</ModulusAssemblyDomain>
40-
<OutputPath>..\..\..\..\artifacts\Modules\{ModuleName}\</OutputPath>
40+
<OutputPath>..\..\..\..\artifacts\bin\Modules\{ModuleName}\</OutputPath>
4141
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
4242
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
4343
</PropertyGroup>
4444
```
4545

4646
This automatically generates `[AssemblyDomain]` attribute and `MODULUS_SHARED_DOMAIN` / `MODULUS_MODULE_DOMAIN` compile-time constants.
4747

48+
### Artifacts Directory Structure
49+
50+
```
51+
artifacts/
52+
├── bin/ # Host apps + shared assemblies + modules
53+
│ ├── Modulus.Host.Avalonia.exe
54+
│ ├── Modulus.Core.dll
55+
│ └── Modules/ # Module compilation outputs
56+
│ ├── EchoPlugin/
57+
│ ├── ComponentsDemo/
58+
│ └── SimpleNotes/
59+
├── cli/ # CLI tool (modulus.exe)
60+
├── tests/ # Test assemblies
61+
├── packages/ # CLI NuGet packages (.nupkg)
62+
└── ModulesInstaller/ # Module installer packages (.modpkg)
63+
```
64+
4865
### Output Path Rules
4966

50-
| Project Location | Import Path | OutputPath |
51-
|-----------------|-------------|------------|
52-
| `src/*/*.csproj` | `..\..\build\` | `..\..\artifacts\` |
53-
| `src/*/*/*.csproj` | `..\..\..\build\` | `..\..\..\artifacts\` |
54-
| `tests/*/*.csproj` | `..\..\build\` | `..\..\artifacts\` |
55-
| `src/Modules/*/*/*.csproj` | `..\..\..\..\build\` | `..\..\..\..\artifacts\Modules\{ModuleName}\` |
67+
| Project Type | Location | OutputPath |
68+
|-------------|----------|------------|
69+
| Shared assemblies | `src/*/*.csproj` | `..\..\artifacts\bin\` |
70+
| Host projects | `src/Hosts/*/*.csproj` | `..\..\..\artifacts\bin\` |
71+
| CLI tool | `src/Modulus.Cli/*.csproj` | `..\..\artifacts\cli\` |
72+
| Test projects | `tests/*/*.csproj` | `..\..\artifacts\tests\` |
73+
| Module assemblies | `src/Modules/*/*/*.csproj` | `..\..\..\..\artifacts\bin\Modules\{ModuleName}\` |
5674

5775
### Shared Assembly Allowlist
5876

.nuke/build.schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@
3333
"Compile",
3434
"Default",
3535
"Pack",
36+
"PackCli",
37+
"PackModule",
3638
"Plugin",
39+
"PublishCli",
3740
"Restore",
3841
"Run",
3942
"Test"

Modulus.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modulus.UI.Avalonia.Tests",
6767
EndProject
6868
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modulus.Infrastructure.Data", "src\Shared\Modulus.Infrastructure.Data\Modulus.Infrastructure.Data.csproj", "{27F8D10F-EB5E-4903-8FBA-07457612C088}"
6969
EndProject
70+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Modulus.Cli", "src\Modulus.Cli\Modulus.Cli.csproj", "{88BEB284-8152-4207-91D2-4A26BBC341D4}"
71+
EndProject
7072
Global
7173
GlobalSection(SolutionConfigurationPlatforms) = preSolution
7274
Debug|Any CPU = Debug|Any CPU
@@ -364,6 +366,18 @@ Global
364366
{27F8D10F-EB5E-4903-8FBA-07457612C088}.Release|x64.Build.0 = Release|Any CPU
365367
{27F8D10F-EB5E-4903-8FBA-07457612C088}.Release|x86.ActiveCfg = Release|Any CPU
366368
{27F8D10F-EB5E-4903-8FBA-07457612C088}.Release|x86.Build.0 = Release|Any CPU
369+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
370+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
371+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Debug|x64.ActiveCfg = Debug|Any CPU
372+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Debug|x64.Build.0 = Debug|Any CPU
373+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Debug|x86.ActiveCfg = Debug|Any CPU
374+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Debug|x86.Build.0 = Debug|Any CPU
375+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
376+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Release|Any CPU.Build.0 = Release|Any CPU
377+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Release|x64.ActiveCfg = Release|Any CPU
378+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Release|x64.Build.0 = Release|Any CPU
379+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Release|x86.ActiveCfg = Release|Any CPU
380+
{88BEB284-8152-4207-91D2-4A26BBC341D4}.Release|x86.Build.0 = Release|Any CPU
367381
EndGlobalSection
368382
GlobalSection(SolutionProperties) = preSolution
369383
HideSolutionNode = FALSE
@@ -398,5 +412,6 @@ Global
398412
{07C30195-C5FD-4B14-86AB-3CE59E5C9CF8} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
399413
{6D47D1B4-A5E3-4BD6-B857-7845F59E4076} = {0AB3BF05-4346-4AA6-1389-037BE0695223}
400414
{27F8D10F-EB5E-4903-8FBA-07457612C088} = {C8E42992-5E42-0C2B-DBFE-AA848D06431C}
415+
{88BEB284-8152-4207-91D2-4A26BBC341D4} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B}
401416
EndGlobalSection
402417
EndGlobal

README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,69 @@ public class MyExtensionPackage : ModulusPackage
121121
modulus install ./MyExtension
122122
```
123123

124+
## 🛠️ CLI Tool
125+
126+
Modulus provides a command-line tool for module management.
127+
128+
### Install CLI
129+
130+
```bash
131+
# Install from NuGet (available after publishing)
132+
dotnet tool install -g Agibuild.Modulus.Cli
133+
134+
# Or install from local build
135+
dotnet tool install -g --add-source ./artifacts/packages Agibuild.Modulus.Cli
136+
137+
# During development, use directly
138+
./artifacts/cli/modulus.exe
139+
```
140+
141+
### Install Module
142+
143+
```bash
144+
# Install from .modpkg file
145+
modulus install ./MyModule-1.0.0.modpkg
146+
147+
# Install from directory (for development)
148+
modulus install ./artifacts/bin/Modules/MyModule/
149+
150+
# Force overwrite existing installation
151+
modulus install ./MyModule-1.0.0.modpkg --force
152+
```
153+
154+
### Uninstall Module
155+
156+
```bash
157+
# Uninstall by module name
158+
modulus uninstall MyModule
159+
160+
# Uninstall by module ID
161+
modulus uninstall a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d
162+
163+
# Skip confirmation
164+
modulus uninstall MyModule --force
165+
```
166+
167+
### List Installed Modules
168+
169+
```bash
170+
# Basic list
171+
modulus list
172+
173+
# Show detailed information
174+
modulus list --verbose
175+
```
176+
177+
### Package Module
178+
179+
```bash
180+
# Package all modules to artifacts/packages/
181+
nuke pack-module
182+
183+
# Package a single module
184+
nuke pack-module --name EchoPlugin
185+
```
186+
124187
## 📚 Documentation
125188

126189
- [OpenSpec Specifications](./openspec/specs/)

README.zh-CN.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,69 @@ public class MyExtensionPackage : ModulusPackage
121121
modulus install ./MyExtension
122122
```
123123

124+
## 🛠️ CLI 工具
125+
126+
Modulus 提供命令行工具用于模块管理。
127+
128+
### 安装 CLI
129+
130+
```bash
131+
# 从 NuGet 安装(发布后可用)
132+
dotnet tool install -g Agibuild.Modulus.Cli
133+
134+
# 或从本地构建安装
135+
dotnet tool install -g --add-source ./artifacts/packages Agibuild.Modulus.Cli
136+
137+
# 开发时直接使用
138+
./artifacts/cli/modulus.exe
139+
```
140+
141+
### 安装模块
142+
143+
```bash
144+
# 从 .modpkg 文件安装
145+
modulus install ./MyModule-1.0.0.modpkg
146+
147+
# 从目录安装(开发用)
148+
modulus install ./artifacts/bin/Modules/MyModule/
149+
150+
# 强制覆盖已有安装
151+
modulus install ./MyModule-1.0.0.modpkg --force
152+
```
153+
154+
### 卸载模块
155+
156+
```bash
157+
# 按模块名称卸载
158+
modulus uninstall MyModule
159+
160+
# 按模块 ID 卸载
161+
modulus uninstall a1b2c3d4-e5f6-4a7b-8c9d-0e1f2a3b4c5d
162+
163+
# 跳过确认
164+
modulus uninstall MyModule --force
165+
```
166+
167+
### 列出已安装模块
168+
169+
```bash
170+
# 基本列表
171+
modulus list
172+
173+
# 显示详细信息
174+
modulus list --verbose
175+
```
176+
177+
### 打包模块
178+
179+
```bash
180+
# 打包所有模块到 artifacts/packages/
181+
nuke pack-module
182+
183+
# 打包单个模块
184+
nuke pack-module --name EchoPlugin
185+
```
186+
124187
## 📚 文档
125188

126189
- [OpenSpec 规格说明](./openspec/specs/)

0 commit comments

Comments
 (0)