In .NET Framework, the loader searches dependencies in current folder and then in GAC.
But in .NET Core there is no GAC, so does .NET Core assembly loader only search assemblies in current folder or in global nuget cache(someuser/.nuget/packages folder) also?
Also I found a /usr/local/share/dotnet/shared folder in my Mac(C:\Program Files\dotnet\shared in Windows) where all base libraries are located, like System.Runtime.dll, System.Collections.dll.
Does assembly loader looks there too?
Also I found that these base libraries are duplicated also in in global nuget cache.
Why?
The directories used by the PackageCompilationAssemblyResolver will be largely dependent on your environment. However, they may include:
Note that this is just for packages (i.e NuGet). Other assembly resolvers exist for references and application assemblies...
Note that if you are using an assembly resolver directly in your code, you can specify the paths used for resolution as follows:
ICompilationAssemblyResolver assemblyResolver = new CompositeCompilationAssemblyResolver
(new ICompilationAssemblyResolver[]
{
new AppBaseCompilationAssemblyResolver(basePath), //e.g. project path
new ReferenceAssemblyPathResolver(defaultReferenceAssembliesPath, fallbackSearchPaths),
new PackageCompilationAssemblyResolver(nugetPackageDirectory) //e.g. C:\Users\\{user}\\.nuget\packages
});
For more details on managing the resolution of assemblies within you code, see this article - Resolving Assemblies in .NET Core
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With