These days, with .NET 5+, we can extend the AssemblyLoadContext class with "isCollectible: true" to enable unloading temporary assemblies.
This blog post goes into some more detail: https://medium.com/@vikkasjindal/assemblyloadcontext-in-c-bbaacd692989