Skip to content

Add dll deploy support - #21

Merged
beyro merged 14 commits into
mainfrom
beyro/add-dll-deploy-support
Oct 9, 2026
Merged

beyro merged 14 commits into
mainfrom
beyro/add-dll-deploy-support

Conversation

@beyro

@beyro beyro commented Oct 8, 2026

Copy link
Copy Markdown
Owner

Adds an assembly build mode to plugin deploy/sync (config: pluginBuildMode; default stays package)

  • Assembly mode: builds the DLL, creates/updates the pluginassembly, registers plugintype rows for each plugin class, and prunes types for removed classes (before the content update).
  • Package mode: unchanged, except it now fails loudly if no .nupkg is produced.
  • deploy gains --dry-run.

309 tests pass; verified fresh deploy, rename, and removal against a dev org.

beyro added 14 commits October 8, 2026 16:22
Tasks 1-3 of the bare DLL deployment plan:

- Add PluginBuildMode enum, AppConfig.pluginBuildMode, ConfigLoader.ResolvePluginBuildMode,
  and the --plugin-build-mode CLI option (deploy/sync).
- ProjectBuilder: add BuildAssembly which tolerates projects that emit no .nupkg and make
  BuildResult.NupkgPath nullable; extract a virtual RunBuild seam for testing.
- Introduce IPluginDeployer + PluginArtifact and PluginDeployerBase shared skeleton; refactor
  PackageDeployer onto the base while keeping its existing public Deploy overload.
- Add ConfigLoaderTests and ProjectBuilderTests.
Tasks 4-7 of the bare DLL deployment plan:

- AssemblyDeployer: create or update a pluginassembly from the built .dll, resolve by name
  (throw on duplicates), dry-run reports "would create".
- SolutionService.AddAssemblyToSolution (component type 91).
- PluginDeploymentPlan: maps requested mode + build output to the artifact deployed, warning
  when they disagree (E18).
- Wire plugin deploy/sync: resolve mode, select deployer, warn on mismatch, add the assembly
  to the target solution; add --dry-run to plugin deploy.
- README: document --plugin-build-mode, pluginBuildMode, assembly-mode semantics and
  solution membership.
- Tests: AssemblyDeployerTests, PluginDeploymentPlanTests, AddAssemblyToSolution.
Package mode now fails when the build emits no .nupkg instead of falling back to the DLL.
Assembly mode keeps the E18 warning when a .nupkg was also produced. PluginDeploymentPlan no
longer carries a (never-changing) mode, and commands select the deployer from the resolved mode.
Update README and the plan's E18 resolution note.
Review-driven changes:
- Extract PluginDeployRunner.BuildAndDeploy; both commands share one build+deploy path.
- Compute the assembly Version only in assembly mode (package path no longer opens the DLL).
- Add PluginDeploymentPlan.ShouldAddAssemblyToSolution and unit-test the guard truth table.
- Rename ProjectBuilder.BuildAssembly -> BuildAllowingMissingPackage (the real distinction is
  package-optional, not assembly-specific).
- Remove the production-dead PackageDeployer.Deploy(string,string) overload; point its tests at
  the PluginArtifact API.
- Assert version + exact base64 content in AssemblyDeployerTests; drop the over-claiming name.
- Docs: deploy description, pluginassembly table row, test header, plan doc drift.
A bare pluginassembly upload does not make Dataverse create the child plugintype rows
(unlike a pluginpackage, which Dataverse extracts itself), so sync could not register steps -
"No plugintype records found for assembly".

Mirror the Plugin Registration Tool / spkl: reflect the built DLL for every concrete IPlugin
class and create the missing plugintype records.

- PluginDiscovery.DiscoverPluginTypeNames + shared metadata-load path (ForEachPluginType).
- New PluginTypeRegistrar.EnsureRegistered (create missing, skip existing).
- PluginDeployRunner registers types after an assembly-mode deploy (not on dry run).
- Tests: PluginTypeRegistrarTests, PluginDiscoveryTests; README + plan notes.
A removed/renamed plugin class left its plugintype row behind forever. In assembly mode dvx
creates those rows itself, so it must also reconcile them.

- PluginTypeRegistrar.DeleteOrphans: deletes types absent from the built DLL, scoped to the
  deployed assembly; deletes each orphan's steps first; never touches types backing a Custom
  API (SdkMetadata.CustomApiPluginTypeIds) or Custom Action (new CustomActionPluginTypeIds,
  which required adding workflow.plugintypeid to the SdkMetadata query); no writes on dry-run;
  refuses to delete when the desired set is empty (reflection-failure safety rail).
- PluginDeployRunner: in assembly mode reflect the DLL once, EnsureRegistered then, when
  --delete-orphaned, DeleteOrphans. Package mode unchanged (Dataverse prunes on package update).
- plugin deploy gains --delete-orphaned (reusing the existing option; no new flag).
- Tests: 8 new PluginTypeRegistrar cases. README + plan updated.
Dataverse validates every registered plugintype against the incoming assembly during the
pluginassembly content update and rejects it ("PluginType [...] not found in PluginAssembly
[...]") when a removed class's type still exists. The previous code pruned orphans AFTER the
update, so the update failed first.

- Move type reconciliation before the update, unconditionally (spkl-style) — a stale type makes
  the update impossible, so it is not an optional cleanup.
- New PluginDeployRunner.DeployAssembly seam (internal): find existing id -> DeleteOrphans ->
  deploy content -> EnsureRegistered. Unit-tested (PluginDeployRunnerTests) for the ordering.
- AssemblyDeployer.FindExistingId(name) exposed.
- deploy no longer takes --delete-orphaned (types reconcile automatically); --delete-orphaned
  stays steps-only for sync/register.
- README + plan updated.

Verified red-first: PluginDeployRunnerTests failed to compile before DeployAssembly existed.
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

@beyro
beyro merged commit 80f830d into main Oct 9, 2026
2 checks passed
@beyro
beyro deleted the beyro/add-dll-deploy-support branch October 9, 2026 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant