public async Task Test_DependencyWalkerObtainer_fetches_x64_and_x86() { var path = Path.Combine(TestDataRoot, "new_dir"); var d = new DependencyWalkerObtainer(path); await d.DownloadFiles(); Assert.That(Directory.GetFiles(path, "*.exe", SearchOption.AllDirectories), Has.Exactly(2).Items); }
static void Execute(string[] args) { Console.WriteLine("Starting dependency download"); if (args.Length < 1) { throw new ArgumentException("First argument must be directory for dependency walker"); } var path = args[0]; string user = null; string password = null; if (args.Length == 3) { user = args[1]; password = args[2]; } if (Directory.Exists(path) == false) { Directory.CreateDirectory(path); } Console.WriteLine($"Deleting sub directories in {path}"); // Make sure this directory is empty foreach (var directoryInfo in new DirectoryInfo(path).GetDirectories()) { directoryInfo.Delete(true); } Console.WriteLine($"Downloading depends to {path}"); var d = new DependencyWalkerObtainer(path, user, password); d.DownloadFiles().GetAwaiter().GetResult(); var exeFiles = Directory.GetFiles(path, "*.exe", SearchOption.AllDirectories).Length; if (exeFiles != 2) { throw new InvalidOperationException($"Expected two executables, found {exeFiles}"); } }
private static string _getDependencyWalkerIfMissing(ConsoleLogger logger, string proxyUser, string proxyPassword) { var current = Environment.CurrentDirectory; var dirName = "DependencyWalker"; var finalDir = Path.Combine(current, dirName); if (Directory.Exists(finalDir)) { return(finalDir); // all set } logger.Warn("Detected missing dependency walker. Trying to obtain"); // Missing depends. Download var dwo = new DependencyWalkerObtainer(finalDir, proxyUser, proxyPassword); try { dwo.DownloadFiles().Wait(); var fileCount = Directory.GetFiles(finalDir, "*.exe", SearchOption.AllDirectories).Length; if (fileCount != 2) { // Remove directory because this would prevent a download next time throw new InvalidOperationException($"Failed to obtain dependency walker. Expected two executables to find in {finalDir}, found {fileCount}"); } } catch (Exception) { Directory.Delete(finalDir, true); throw; } logger.Info("Successfully obtained dependency walker"); return(finalDir); }