Skip to content

Conversation

dxqwww
Copy link
Contributor

@dxqwww dxqwww commented Aug 22, 2025

Hello, let me introduce an expiremental plugin dependency resolver to improve how external dependencies are resolved when loading plugins.

Problem

By default, McMaster.NETCore.Plugins does not handle scenarios where NuGet packages need to be loaded from a shared/global location. To address this, I implemented a custom resolver that can locate dependencies in the NuGet packages root folder (either from the NUGET_PACKAGES environment variable or the default .nuget/packages location).

Motivation

Previously, for every plugin that depended on a NuGet package, you had to manually place the assemblies into the shared folder. These changes remove that friction by enabling automatic resolution.

Configuration

Since this feature is experimental, it is disabled by default.
To enable it, set the following in core.json:

"UseExperimentalPluginDependencyResolver": true

@dxqwww dxqwww requested a review from roflmuffin as a code owner August 22, 2025 15:49
@KillStr3aK
Copy link
Contributor

KillStr3aK commented Aug 22, 2025

mind elaborate? there is already an option to put dependencies in the shared folder (and it is intended)

@dxqwww
Copy link
Contributor Author

dxqwww commented Aug 22, 2025

mind elaborate? there is already an option to put dependencies in the shared folder (and it is intended)

Yeah sure, by design plugin dependencies (like NuGet packages) can already be resolved by copying them into the shared folder. This works, but it requires every NuGet dependency of every plugin to be manually mirrored there, which quickly becomes tedious.

This NuGet resolver doesn't replace the shared folder mechanism but complements it. Instead of forcing all dependencies into shared manually, the resolver could automatically locate them in the system NuGet packages root. This reduces manual setup while keeping the original shared approach available.

@dxqwww
Copy link
Contributor Author

dxqwww commented Aug 22, 2025

Here is real use case issue:

When a plugin references a NuGet package that isn't copied yet into the shared loading fails. The assembly is present in the local NuGet cache and is the same way we resolve CounterStrikeSharp.API, but any attempt to use it either from plugins or other shared projects throws at load time.

This problem is fully reproducible with McMaster.NETCore.Plugins library.

Similar issues:

natemcmaster/DotNetCorePlugins#294
natemcmaster/DotNetCorePlugins#300
natemcmaster/DotNetCorePlugins#302

img

roflmuffin
roflmuffin previously approved these changes Sep 8, 2025
@roflmuffin
Copy link
Owner

Sorry for the delay in reviewing this one. Would you be able to add the new config section to the example.json and also the documentation for core config?

https://github.com/roflmuffin/CounterStrikeSharp/blob/main/configs/addons/counterstrikesharp/configs/core.example.json

@dxqwww
Copy link
Contributor Author

dxqwww commented Sep 9, 2025

Sorry for the delay in reviewing this one. Would you be able to add the new config section to the example.json and also the documentation for core config?

https://github.com/roflmuffin/CounterStrikeSharp/blob/main/configs/addons/counterstrikesharp/configs/core.example.json

Yes, sure

@dxqwww
Copy link
Contributor Author

dxqwww commented Sep 10, 2025

@roflmuffin I've added some documentation for this feature. Let me know if it meets your needs

@roflmuffin roflmuffin enabled auto-merge (squash) October 18, 2025 01:01
@roflmuffin
Copy link
Owner

@dxqwww Can you either allow contributors to edit this branch or pull latest main into your branch to allow automerge to go through?

@roflmuffin roflmuffin merged commit b4ba7d8 into roflmuffin:main Oct 18, 2025
5 checks passed
@dxqwww
Copy link
Contributor Author

dxqwww commented Oct 18, 2025

🎉

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.

3 participants