Description
Thank you for this repo, lots of information in there!
I'm trying to understand if there's a way to adapt those approaches in modules written in PowerShell.
Let me describe my scenario, what I understand, and what I think I don't know...
Scenario
I would like to fork & rename the Powershell-Yaml module to experiment with some things, while I still use the Powershell-Yaml
module (i.e. for building that module).
- I'd like my fork to be able to use a newer version of the YamlDotNet assembly
- I don't want to wrap YamlDotNet in another assembly
- I think I need the assembly resolution to work at module parse time
What I think I understand
- As the YamlDotNet library is compatible with netstandard 2.0, I can use the same dll for PS 5.1 AND PS 7+.
- The dependency of YamlDotNet is at the 'class-level' (well, parse time for my new PS module) so it's closer to scenario 2 described in your repo here.
- As per your sample:
the registration of AssemblyResolve needs to happen in a separate assembly (resolver.dll in this sample), which needs to be loaded before the above assembly"
What I'd like clarification/guidance on
Could the resolver DLL be loaded before parse time using RequiredAssemblies or ScriptToProcess in the ModuleManifest?
If I list the assemblies in the module manifest, like so, should it work?
RequiredAssemblies = @('resolver.dll','conflict.dll')
Will the loading order be respected (so that registration of AssemblyResolve
happen first)?
Why don't you use this approach in your sample and prefer a nested module? Is it for the OnImport() call?
Are nested module (resolver.dll) loaded before the RootModule psm1 is parsed?
Since the module (let's call it MyModule) isn't a binary module, in IsAssemblyMatching()
the requestingAssembly will be null? Does that mean I can't select which library will it resolve to, so anything calling it in my PowerShell session will now go to that newer lib?
Thanks for the clarification!