cloudbase / powershell-yaml

PowerShell CmdLets for YAML format manipulation
Apache License 2.0
434 stars 78 forks source link

Use LoadFile() and resolve dependencies manually #141

Closed gabriel-samfira closed 3 months ago

gabriel-samfira commented 3 months ago

LoadFile() works on both dotnet Framework 47 and dotnet Core. The downside is that we need to manually resolve dependencies for the custom serializer assembly on dotnet Core. On dotnet Framework there seems to be different behavior in terms of assembly resolution, and as long as the required assembly is in the same folder as the requesting assembly, it loads fine.

gabriel-samfira commented 3 months ago

CC @splatteredbits

I took your advice and went with LloadFile() in the end. Dependency resolution rules are such a mess. On .Net Framework, LoadFile() seems to have automatic resolution. In fact, registering a handler for the AssemblyResolve() event on Windows Server 2016, breaks when running inside a Start-Job script block.

On dotnet core however, this handler is absolutely needed.

Let me know if you have any thoughts on this PR or if you see anything really funky.

gabriel-samfira commented 3 months ago

merging this. Will revert before release if it turns out to be a bad idea.