Aspnetcore: ASP.net Core RC2 Scan and Load Assemblies from Bin Folder

Created on 22 May 2016  路  11Comments  路  Source: dotnet/aspnetcore

I am trying to port an application written in RC1 to RC2. In RC1, we could do something like this:

libraryManager.GetReferencingLibraries("ThisLibrary");
.....

and then load the assemblies. What is the equivalent of loading all assemblies present in the bin folder which depend on ThisLibrary in RC2?

Most helpful comment

Is there any view if/when RuntimeLibrary.Assemblies will be getting populated again (again since the aspnet/Announcements#149 sample output shows them populated at least for some of the packages)?

All 11 comments

It seems it has been moved into different package https://github.com/aspnet/Announcements/issues/149
See DependencyContext.Default in above announcement because Dnx is retired.

I also need this. I was previously doing this under DNX world:

    /// <summary>
    /// Locates the assemblies based on <code>PlatformServices.Default.Application.ApplicationName</code>.
    /// </summary>
    internal static class DefaultAssemblyLocator
    {
        public static IEnumerable<Assembly> Locate() => PlatformServices.Default.LibraryManager
            .GetLibrary(PlatformServices.Default.Application.ApplicationName)
            .Assemblies
            .Select(an => Assembly.Load(an));
    }

What's the equivalent of this now?

Sorry, didn't realize Microsoft.Extensions.DependencyModel on aspnet/Announcements#149 that @imranbaloch mentioned. All seems fine for now. I will migrate there.

@imranbaloch, does DependencyContext really display all libraries from bin folder?

@frapid check this https://github.com/dotnet/cli/blob/master/src/Microsoft.Extensions.DependencyModel/DependencyContext.cs
It can used getting both CompileLibraries and RuntimeLibraries.

@imranbaloch, thank you for the info.

I can confirm that that both Microsoft.Extensions.DependencyModel.DependencyContext.Default.RuntimeLibraries and Microsoft.Extensions.DependencyModel.DependencyContext.Default.CompileLibraries do not detect assemblies present in the bin folder which were copied during a build process of a different project.

Thank you very much. We have decided to return back here after one year or two.

Assemplies is empty for all in list DependencyContext.Default.RuntimeLibraries. http://c2n.me/3yMxqrb

Related to my issue #1554
It seems it's no longer clear how to get the assemblies for some Library via Library manager like we could in RC1. If someone figures it out please comment. In the meantime i'll try stack overflow.

I confirm this is still unresolved in Microsoft.Extensions.DependencyModel 1.0.0 and RuntimeLibrary.Assemblies is always empty.

Is there any view if/when RuntimeLibrary.Assemblies will be getting populated again (again since the aspnet/Announcements#149 sample output shows them populated at least for some of the packages)?

Was this page helpful?
0 / 5 - 0 ratings