public bool Execute() { // 1. Walk the graph of library dependencies var root = LibraryDependencyFinder.Build(_libraryManager.GetLibraryDescriptions(), _options.Project); if (_options.Mismatched) { RenderMismatchedDependencies(root); return(true); } if (!_options.ShowAssemblies) { RenderAllDependencies(root); return(true); } var assemblyPaths = PackageDependencyProvider.ResolvePackageAssemblyPaths(_libraryManager.GetLibraryDescriptions()); // 2. Walk the local dependencies and print the assemblies list var assemblyWalker = new AssemblyWalker(_framework, assemblyPaths, _options.RuntimeFolder, _options.Details, _options.Reports); assemblyWalker.Walk(root); return(true); }
public RuntimeLoadContext(string friendlyName, IEnumerable <LibraryDescription> libraries, ICompilationEngine compilationEngine, IAssemblyLoadContext defaultContext) : base(friendlyName) { // TODO: Make this all lazy // TODO: Unify this logic with default host var projects = libraries.Where(p => p.Type == LibraryTypes.Project) .OfType <ProjectDescription>(); var assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); _projectAssemblyLoader = new ProjectAssemblyLoader(loadContextAccessor: null, compilationEngine: compilationEngine, projects: projects); _packageAssemblyLoader = new PackageAssemblyLoader(loadContextAccessor: null, assemblies: assemblies, libraryDescriptions: libraries); _defaultContext = defaultContext; }
internal void AddCompiler(string compilerDirectory) { DebugMessage("EdgeAssemblyLoadContext::AddCompiler (CLR) - Adding the compiler in {0}", compilerDirectory); ApplicationHostContext compilerHostContext = new ApplicationHostContext { ProjectDirectory = compilerDirectory, TargetFramework = TargetFrameworkName }; IList <LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(compilerHostContext); Dictionary <AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); DebugMessage("EdgeAssemblyLoadContext::AddCompiler (CLR) - Finished"); }
public EdgeAssemblyLoadContext(EdgeAssemblyLoadContextAccessor loadContextAccessor) { DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Starting"); DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Application root is {0}", RuntimeEnvironment.ApplicationDirectory); _loadContextAccessor = loadContextAccessor; if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, "project.lock.json"))) { IList <LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(ApplicationHostContext); Dictionary <string, ProjectDescription> projects = libraries.Where(p => p.Type == LibraryTypes.Project).ToDictionary(p => p.Identity.Name, p => (ProjectDescription)p); Dictionary <AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); CompilationEngineContext compilationContext = new CompilationEngineContext(ApplicationEnvironment, RuntimeEnvironment, this, new CompilationCache()); CompilationEngine compilationEngine = new CompilationEngine(compilationContext); AddCompileAssemblies(libraries); _loaders.Add(new ProjectAssemblyLoader(_loadContextAccessor, compilationEngine, projects.Values)); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } else { _noProjectJsonFile = true; if (File.Exists(Path.Combine(RuntimeEnvironment.EdgeNodePath, "project.lock.json"))) { ApplicationHostContext stockHostContext = new ApplicationHostContext { ProjectDirectory = RuntimeEnvironment.EdgeNodePath, TargetFramework = TargetFrameworkName }; IList <LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(stockHostContext); Dictionary <AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); AddCompileAssemblies(libraries); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } } DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Created the dependency providers for the application"); }
public EdgeAssemblyLoadContext(EdgeAssemblyLoadContextAccessor loadContextAccessor) { DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Starting"); DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Application root is {0}", RuntimeEnvironment.ApplicationDirectory); _loadContextAccessor = loadContextAccessor; if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, "project.lock.json"))) { IList <LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(ApplicationHostContext); Dictionary <string, ProjectDescription> projects = libraries.Where(p => p.Type == LibraryTypes.Project).ToDictionary(p => p.Identity.Name, p => (ProjectDescription)p); Dictionary <AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); CompilationEngineContext compilationContext = new CompilationEngineContext(ApplicationEnvironment, RuntimeEnvironment, this, new CompilationCache()); CompilationEngine compilationEngine = new CompilationEngine(compilationContext); foreach (LibraryDescription libraryDescription in libraries.Where(l => l.Type == LibraryTypes.Package)) { PackageDescription packageDescription = (PackageDescription)libraryDescription; if (packageDescription.Target.CompileTimeAssemblies != null && packageDescription.Target.CompileTimeAssemblies.Count > 0) { CompileAssemblies[libraryDescription.Identity.Name] = Path.Combine(packageDescription.Path, packageDescription.Target.CompileTimeAssemblies[0].Path); } else { CompileAssemblies[libraryDescription.Identity.Name] = Path.Combine(packageDescription.Path, packageDescription.Target.RuntimeAssemblies[0].Path); } } _loaders.Add(new ProjectAssemblyLoader(_loadContextAccessor, compilationEngine, projects.Values)); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } else { _noProjectJsonFile = true; } DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Created the dependency providers for the application"); }
private void Initialize(DefaultHostOptions options, IAssemblyLoadContextAccessor loadContextAccessor) { var applicationHostContext = new ApplicationHostContext { ProjectDirectory = _projectDirectory, RuntimeIdentifiers = _runtimeEnvironment.GetAllRuntimeIdentifiers(), TargetFramework = _targetFramework }; var libraries = ApplicationHostContext.GetRuntimeLibraries(applicationHostContext, throwOnInvalidLockFile: true); Logger.TraceInformation("[{0}]: Project path: {1}", GetType().Name, applicationHostContext.ProjectDirectory); Logger.TraceInformation("[{0}]: Project root: {1}", GetType().Name, applicationHostContext.RootDirectory); Logger.TraceInformation("[{0}]: Project configuration: {1}", GetType().Name, options.Configuration); Logger.TraceInformation("[{0}]: Packages path: {1}", GetType().Name, applicationHostContext.PackagesDirectory); _applicationHostContext = applicationHostContext; _project = applicationHostContext.Project; #if FEATURE_DNX_MIN_VERSION_CHECK ValidateMinRuntimeVersion(libraries); #endif // Create a new Application Environment for running the app. It needs a reference to the Host's application environment // (if any), which we can get from the service provider we were given. // If this is null (i.e. there is no Host Application Environment), that's OK, the Application Environment we are creating // will just have it's own independent set of global data. var hostEnvironment = PlatformServices.Default.Application; var applicationEnvironment = new ApplicationEnvironment(Project, _targetFramework, hostEnvironment); var compilationContext = new CompilationEngineContext( applicationEnvironment, _runtimeEnvironment, loadContextAccessor.Default, new CompilationCache()); var compilationEngine = new CompilationEngine(compilationContext); var runtimeLibraryExporter = new RuntimeLibraryExporter(() => compilationEngine.CreateProjectExporter(Project, _targetFramework, options.Configuration)); var runtimeLibraryManager = new RuntimeLibraryManager(applicationHostContext); // Default services _serviceProvider.Add(typeof(ILibraryExporter), runtimeLibraryExporter); _serviceProvider.Add(typeof(IApplicationEnvironment), applicationEnvironment); _serviceProvider.Add(typeof(IRuntimeEnvironment), PlatformServices.Default.Runtime); _serviceProvider.Add(typeof(ILibraryManager), runtimeLibraryManager); _serviceProvider.Add(typeof(IAssemblyLoadContextAccessor), PlatformServices.Default.AssemblyLoadContextAccessor); _serviceProvider.Add(typeof(IAssemblyLoaderContainer), PlatformServices.Default.AssemblyLoaderContainer); PlatformServices.SetDefault(new ApplicationHostPlatformServices(PlatformServices.Default, applicationEnvironment, runtimeLibraryManager)); if (options.CompilationServerPort.HasValue) { // Change the project reference provider Project.DefaultCompiler = Project.DefaultDesignTimeCompiler; Project.DesignTimeCompilerPort = options.CompilationServerPort.Value; } // TODO: Dedupe this logic in the RuntimeLoadContext var projects = libraries.Where(p => p.Type == Runtime.LibraryTypes.Project) .ToDictionary(p => p.Identity.Name, p => (ProjectDescription)p); var assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); // Configure Assembly loaders _loaders.Add(new ProjectAssemblyLoader(loadContextAccessor, compilationEngine, projects.Values, options.Configuration)); _loaders.Add(new PackageAssemblyLoader(loadContextAccessor, assemblies, libraries)); var compilerOptionsProvider = new CompilerOptionsProvider(projects); _serviceProvider.Add(typeof(ICompilerOptionsProvider), compilerOptionsProvider); CompilationServices.SetDefault( CompilationServices.Create( libraryExporter: runtimeLibraryExporter, compilerOptionsProvider: compilerOptionsProvider ) ); #if DNX451 PackageDependencyProvider.EnableLoadingNativeLibraries(libraries); #endif AddBreadcrumbs(libraries); }
public PackageAssemblyLoader(IAssemblyLoadContextAccessor loadContextAccessor, LibraryManager libraryManager) { _loadContextAccessor = loadContextAccessor; _assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraryManager); }
private void Initialize(RuntimeOptions options, IServiceProvider hostServices, IAssemblyLoadContextAccessor loadContextAccessor, IFileWatcher fileWatcher) { var applicationHostContext = new ApplicationHostContext { ProjectDirectory = _projectDirectory, RuntimeIdentifiers = _runtimeEnvironment.GetAllRuntimeIdentifiers(), TargetFramework = _targetFramework }; var libraries = ApplicationHostContext.GetRuntimeLibraries(applicationHostContext, throwOnInvalidLockFile: true); Logger.TraceInformation("[{0}]: Project path: {1}", GetType().Name, applicationHostContext.ProjectDirectory); Logger.TraceInformation("[{0}]: Project root: {1}", GetType().Name, applicationHostContext.RootDirectory); Logger.TraceInformation("[{0}]: Project configuration: {1}", GetType().Name, options.Configuration); Logger.TraceInformation("[{0}]: Packages path: {1}", GetType().Name, applicationHostContext.PackagesDirectory); _applicationHostContext = applicationHostContext; _project = applicationHostContext.Project; ValidateMinRuntimeVersion(libraries); if (options.WatchFiles) { fileWatcher.OnChanged += _ => { _shutdown.RequestShutdownWaitForDebugger(); }; } // Create a new Application Environment for running the app. It needs a reference to the Host's application environment // (if any), which we can get from the service provider we were given. // If this is null (i.e. there is no Host Application Environment), that's OK, the Application Environment we are creating // will just have it's own independent set of global data. var hostEnvironment = (IApplicationEnvironment)hostServices.GetService(typeof(IApplicationEnvironment)); var applicationEnvironment = new ApplicationEnvironment(Project, _targetFramework, options.Configuration, hostEnvironment); var compilationContext = new CompilationEngineContext( applicationEnvironment, _runtimeEnvironment, loadContextAccessor.Default, new CompilationCache(), fileWatcher); // Compilation services available only for runtime compilation compilationContext.AddCompilationService(typeof(RuntimeOptions), options); compilationContext.AddCompilationService(typeof(IApplicationShutdown), _shutdown); var compilationEngine = new CompilationEngine(compilationContext); // Default services _serviceProvider.Add(typeof(IApplicationEnvironment), applicationEnvironment); _serviceProvider.Add(typeof(ILibraryManager), new RuntimeLibraryManager(applicationHostContext)); _serviceProvider.Add(typeof(ILibraryExporter), new RuntimeLibraryExporter(() => compilationEngine.CreateProjectExporter(Project, _targetFramework, options.Configuration))); _serviceProvider.Add(typeof(IApplicationShutdown), _shutdown); if (options.CompilationServerPort.HasValue) { // Change the project reference provider Project.DefaultCompiler = Project.DefaultDesignTimeCompiler; } CallContextServiceLocator.Locator.ServiceProvider = ServiceProvider; // TODO: Dedupe this logic in the RuntimeLoadContext var projects = libraries.Where(p => p.Type == LibraryTypes.Project) .ToDictionary(p => p.Identity.Name, p => (ProjectDescription)p); var assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); // Configure Assembly loaders _loaders.Add(new ProjectAssemblyLoader(loadContextAccessor, compilationEngine, projects.Values)); _loaders.Add(new PackageAssemblyLoader(loadContextAccessor, assemblies)); _serviceProvider.Add(typeof(ICompilerOptionsProvider), new CompilerOptionsProvider(projects)); AddBreadcrumbs(libraries); }