Skip to content

Add support for extension private deps#1369

Open
jtreminio wants to merge 7 commits intomcmonkeyprojects:masterfrom
jtreminio:extensions-private-deps
Open

Add support for extension private deps#1369
jtreminio wants to merge 7 commits intomcmonkeyprojects:masterfrom
jtreminio:extensions-private-deps

Conversation

@jtreminio
Copy link
Copy Markdown
Contributor

@jtreminio jtreminio commented May 5, 2026

The way this works for me is, in my extension's .csproj file:

  <ItemGroup>
    <Reference Include="ComfyTyped">
      <HintPath>lib/ComfyTyped.dll</HintPath>
    </Reference>
  </ItemGroup>

I've added the ComfyTyped dep to two of my extensions, one with it fully baked in and used, the other with a very small footprint, swarmui builds fine.

This PR's purpose is for each extension to define its own private dependency, where ExtensionA and ExtensionB both depend on LibA but might be different versions.

The simpler solution that does not guard against multiple extensions using the same dependency that might have differing versions is changing return Assembly.LoadFile to return Assembly.LoadFrom here:

Full disclosure as mentioned in Discord but important to note: This PR was created using Claude because C# build and dependency management confuses the heck out of me. I know the two proposed solutions work because I have a full test suite for my extensions, SwarmUI builds, and my extension with its private dependency works great.

Comment thread src/Core/ExtensionsManager.cs Outdated
public List<ExtensionInfo> KnownExtensions = [];

/// <summary>Per-extension load contexts, keyed by extension DLL name. Each extension gets its own <see cref="SwarmExtensionLoadContext"/> so private dependencies stay isolated from other extensions.</summary>
public ConcurrentDictionary<string, SwarmExtensionLoadContext> ExtensionLoadContexts = new();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a retained dict on its own? It doesn't look like there's any reuse, just a single grab on load

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair critique. I've reduced this further.

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.

2 participants