public async Task <IReadOnlyCollection <MetadataReference> > Install(string packageSearchTerm, IReplLogger logger) { var nugetLogger = new NugetErrorLogger(logger); logger.LogOutput($"Searching for {packageSearchTerm}"); var package = await FindPackageAsync(packageSearchTerm, repositories, nugetLogger); if (package == null) { logger.LogError($"Could not find package '{packageSearchTerm}'"); return(Array.Empty <MetadataReference>()); } logger.LogOutput("Found " + Display(package)); logger.LogOutput("Determining dependences..."); var dependencies = await GetPackageDependencies(package, nugetFramework, nugetCache, nugetLogger, repositories); var packagesToInstall = ResolvePackages(package, dependencies, nugetLogger); var packageExtractionContext = new PackageExtractionContext( PackageSaveMode.Defaultv3, XmlDocFileSaveMode.None, clientPolicy, nugetLogger); var assemblyPaths = await Task.WhenAll(packagesToInstall .Select(async packageToInstall => { var installedPath = packagePathResolver.GetInstalledPath(packageToInstall); PackageReaderBase packageReader = installedPath == null ? await DownloadPackage(packageToInstall, packageExtractionContext, nugetLogger) : LocalPackageReader(packageToInstall, installedPath, nugetLogger); var allResources = await Task.WhenAll( packageReader.GetLibItemsAsync(CancellationToken.None), packageReader.GetFrameworkItemsAsync(CancellationToken.None) ); installedPath ??= packagePathResolver.GetInstalledPath(packageToInstall); var references = DotNetAssemblyLocator.GroupDirectoryContentsIntoAssemblies( FilterByFramework(frameworkReducer, allResources.SelectMany(x => x).ToList()) .Select(item => Path.Combine(installedPath, item)) ) .Select(assembly => io.CreateMetadataReferenceWithDocumentation(assembly)) .ToList(); logger.LogOutput("Installation complete for " + Display(packageToInstall)); return(references); }) ); return(assemblyPaths .SelectMany(assemblyGroup => assemblyGroup) .ToList()); }
public async Task <LineEvaluationResult> HandleAsync(Guid lineId, string input, IReplLogger logger) { string assemblyFile = input.Substring(CommandPrefix.Length).Trim('"'); var assemblies = DotNetAssemblyLocator .GroupDirectoryContentsIntoAssemblies(ReadAssembly(assemblyFile)) .Select(assembly => io.CreateMetadataReferenceWithDocumentation(assembly)); foreach (var assembly in assemblies) { logger.LogOutput("Referencing " + assembly.Display); await scriptEvaluator.AddReferences(assembly); workspaceManager.CreateOrUpdateSubmission(lineId, assemblyReferences: assembly); logger.LogOutput("Assembly successfully referenced"); } return(LineEvaluationResult.NoOutput); }
public void LogWarning(string data) => logger.LogOutput(data);