Ejemplo n.º 1
0
        public PackageAssemblyLoader(NuGetFramework runtimeFramework, IAssemblyLoadContextAccessor loadContextAccessor, IEnumerable<Library> libraries, PackagePathResolver pathResolver)
        {
            Log = RuntimeLogging.Logger<PackageAssemblyLoader>();
            _loadContextAccessor = loadContextAccessor;

            _assemblyLookupTable = InitializeAssemblyLookupTable(libraries, runtimeFramework, pathResolver);
        }
Ejemplo n.º 2
0
 public LibraryExporter(
     NuGetFramework targetFramework,
     PackagePathResolver packagePathResolver)
 {
     _targetFramework = targetFramework;
     _packagePathResolver = packagePathResolver;
 }
Ejemplo n.º 3
0
        private Dictionary<string, string> InitializeAssemblyLookupTable(IEnumerable<Library> libraries, NuGetFramework runtimeFramework, PackagePathResolver pathResolver)
        {
            using (Log.LogTimedMethod())
            {
                Log.LogInformation("Scanning resolved Package libraries for assemblies");
                var lookup = new Dictionary<string, string>();
                foreach (var library in libraries)
                {
                    Debug.Assert(library.Identity.Type == LibraryTypes.Package);

                    Log.LogDebug($"Scanning library {library.Identity.Name} {library.Identity.Version}");
                    var lockFileLib = library.GetRequiredItem<LockFileLibrary>(KnownLibraryProperties.LockFileLibrary);
                    var lockFileFrameworkGroup = library.GetItem<LockFileFrameworkGroup>(KnownLibraryProperties.LockFileFrameworkGroup);
                    if (lockFileFrameworkGroup != null)
                    {
                        foreach (var assembly in lockFileFrameworkGroup.RuntimeAssemblies)
                        {
                            Log.LogDebug($"Locating {assembly} in {library.Identity.Name} {library.Identity.Version}");
                            string asmName = Path.GetFileNameWithoutExtension(assembly);
                            if (Log.IsEnabled(LogLevel.Warning) && lookup.ContainsKey(asmName))
                            {
                                Log.LogWarning($"{asmName} already exists at {lookup[asmName]}. Overriding!");
                            }

                            // Locate the package
                            var packageRoot = pathResolver.ResolvePackagePath(lockFileLib.Sha, lockFileLib.Name, lockFileLib.Version);

                            // Resolve the assembly path
                            var assemblyLocation = Path.Combine(packageRoot, assembly);

                            lookup[asmName] = assemblyLocation;
                        }
                    }
                    else
                    {
                        Log.LogDebug($"No assemblies in {library.Identity.Name} {library.Identity.Version} for {runtimeFramework}");
                    }
                }

                return lookup;
            }
        }
Ejemplo n.º 4
0
 public PackageAssemblyLoaderFactory(PackagePathResolver packagePathResolver)
 {
     _packagePathResolver = packagePathResolver;
 }