public Assembly Load(string name) {
            Project project;

            if (!Project.TryGetProject(_virtualPathProvider.Combine(_path, name), out project)) {
                return null;
            }

            var cache = (ICache)_serviceProvider.GetService(typeof(ICache));

            var target = new LibraryKey {
                Name = name,
                Configuration = _applicationEnvironment.Configuration,
                TargetFramework = project.GetTargetFramework(_applicationEnvironment.RuntimeFramework).FrameworkName
            };

            ModuleLoaderContext moduleContext = new ModuleLoaderContext(
                _serviceProvider,
                project.ProjectDirectory);

            moduleContext.DependencyWalker.Walk(name, project.Version, target.TargetFramework);

            var cacheContextAccessor = (ICacheContextAccessor)_serviceProvider.GetService(typeof(ICacheContextAccessor));
            var loadContextFactory = (IAssemblyLoadContextFactory)_serviceProvider.GetService(typeof(IAssemblyLoadContextFactory)) ?? new AssemblyLoadContextFactory(_serviceProvider);

            var compiler = new InternalRoslynCompiler(
               cache,
               cacheContextAccessor,
               new NamedCacheDependencyProvider(),
               loadContextFactory,
               _fileWatcher,
               _applicationEnvironment,
               _serviceProvider);

            _orchardLibraryManager.AddAdditionalRegistrations(moduleContext.DependencyWalker.Libraries);

            var exports = ProjectExportProviderHelper.GetExportsRecursive(
                cache,
                _orchardLibraryManager,
                moduleContext.LibraryExportProvider,
                target,
                true);

            _orchardLibraryManager.AddAdditionalLibraryExportRegistrations(name, exports);

            foreach (var dependency in project.Dependencies) {
                if (!_orchardLibraryManager.MetadataReferences.ContainsKey(dependency.Name))
                    continue;

                exports.MetadataReferences.Add(_orchardLibraryManager.MetadataReferences[dependency.Name]);
            }

            var compliationContext = compiler.CompileProject(project,
                target,
                exports.MetadataReferences,
                exports.SourceReferences);
            
            var roslynProjectReference = new RoslynProjectReference(compliationContext);

            _orchardLibraryManager.AddMetadataReference(name, roslynProjectReference);

            var loadContext = _assemblyLoadContextAccessor.Default;
            return roslynProjectReference.Load(loadContext);
        }
        public Assembly Load(AssemblyName assemblyName)
        {
            Project project;
            string name = assemblyName.FullName;
            if (!Project.TryGetProject(_virtualPathProvider.Combine(_path, name), out project)) {
                return null;
            }

            return _cache.Get<Assembly>(assemblyName.Name, cacheContext => {
                var target = new CompilationTarget(
                    name,
                    project.GetTargetFramework(_applicationEnvironment.RuntimeFramework).FrameworkName,
                    _applicationEnvironment.Configuration,
                    null);

                _moduleContext = new ModuleLoaderContext(
                    _serviceProvider,
                    project.ProjectDirectory,
                    target.Configuration,
                    target.TargetFramework);

                foreach (var lib in _moduleContext.DependencyWalker.Libraries) {
                    _libraryManager.AddLibrary(lib.ToLibrary());
                }

                var compilationEngineFactory = new CompilationEngineFactory(
                    NoopWatcher.Instance, new CompilationCache());

                var engine = compilationEngineFactory.CreateEngine(new CompilationEngineContext(
                    _moduleContext.LibraryManager,
                    _moduleContext.ProjectGraphProvider,
                    _moduleContext.ServiceProvider,
                    target.TargetFramework,
                    target.Configuration));

                _packageAssemblyLookup.AddLoader(
                    _moduleContext.NuGetDependencyProvider);

                var p = engine.LoadProject(project, null, _assemblyLoadContextAccessor.Default);

                var exports = engine.RootLibraryExporter.GetExport(project.Name);
                foreach (var metadataReference in exports.MetadataReferences) {
                    _libraryManager.AddMetadataReference(metadataReference);
                }

                return p;
            });
        }