mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
C#: Parallelize restore logic of missing packages
This commit is contained in:
@@ -37,6 +37,13 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
}
|
||||
}
|
||||
|
||||
private bool RunCommand(string args, out string stdout)
|
||||
{
|
||||
var success = dotnetCliInvoker.RunCommand(args, out var output);
|
||||
stdout = string.Join("\n", output);
|
||||
return success;
|
||||
}
|
||||
|
||||
private static string GetRestoreArgs(string projectOrSolutionFile, string packageDirectory) =>
|
||||
$"restore --no-dependencies \"{projectOrSolutionFile}\" --packages \"{packageDirectory}\" /p:DisableImplicitNuGetFallbackFolder=true";
|
||||
|
||||
@@ -47,9 +54,8 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
{
|
||||
args += $" --configfile \"{pathToNugetConfig}\"";
|
||||
}
|
||||
var success = dotnetCliInvoker.RunCommand(args, out var output);
|
||||
stdout = string.Join("\n", output);
|
||||
return success;
|
||||
|
||||
return RunCommand(args, out stdout);
|
||||
}
|
||||
|
||||
public bool RestoreSolutionToDirectory(string solutionFile, string packageDirectory, out IEnumerable<string> projects)
|
||||
@@ -70,16 +76,16 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool New(string folder)
|
||||
public bool New(string folder, out string stdout)
|
||||
{
|
||||
var args = $"new console --no-restore --output \"{folder}\"";
|
||||
return dotnetCliInvoker.RunCommand(args);
|
||||
return RunCommand(args, out stdout);
|
||||
}
|
||||
|
||||
public bool AddPackage(string folder, string package)
|
||||
public bool AddPackage(string folder, string package, out string stdout)
|
||||
{
|
||||
var args = $"add \"{folder}\" package \"{package}\" --no-restore";
|
||||
return dotnetCliInvoker.RunCommand(args);
|
||||
return RunCommand(args, out stdout);
|
||||
}
|
||||
|
||||
public IList<string> GetListedRuntimes() => GetListed("--list-runtimes", "runtime");
|
||||
@@ -88,7 +94,7 @@ namespace Semmle.Extraction.CSharp.DependencyFetching
|
||||
|
||||
private IList<string> GetListed(string args, string artifact)
|
||||
{
|
||||
if (dotnetCliInvoker.RunCommand(args, out var artifacts))
|
||||
if (dotnetCliInvoker.RunCommand(args, out IList<string> artifacts))
|
||||
{
|
||||
progressMonitor.LogInfo($"Found {artifact}s: {string.Join("\n", artifacts)}");
|
||||
return artifacts;
|
||||
|
||||
Reference in New Issue
Block a user