示例#1
0
        private string InstallDotnetCliTool()
        {
            ExternalToolsManager.Log($"Installing {this.settings.Name} as we could not find it from {this.settings.CommandPath}.");

            Process p = new Process();

            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardInput  = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError  = true;
            p.StartInfo.CreateNoWindow         = true;
            p.StartInfo.FileName  = "dotnet";
            p.StartInfo.Arguments = $"tool install {this.settings.Name} --tool-path {this.settings.CommandPath} --version {this.settings.Version}";
            p.Start();

            string output   = p.StandardOutput.ReadToEnd();
            string errorMsg = p.StandardError.ReadToEnd();

            p.StandardOutput.Close();
            p.StandardError.Close();

            if (!String.IsNullOrEmpty(errorMsg))
            {
                ExternalToolsManager.Log($"Installation failed: {errorMsg}");
            }
            else
            {
                ExternalToolsManager.Log("Done.");
            }

            return(output);
        }
        private void RunCmd(string cmdName, string arguments)
        {
            Process p = new Process();

            p.StartInfo.UseShellExecute        = false;
            p.StartInfo.RedirectStandardInput  = false;
            p.StartInfo.RedirectStandardOutput = true;
            p.StartInfo.RedirectStandardError  = true;
            p.StartInfo.CreateNoWindow         = true;
            p.StartInfo.FileName  = cmdName;
            p.StartInfo.Arguments = $"{arguments}";
            p.Start();

            string outputBinary = p.StandardOutput.ReadToEnd();
            string errorMsg     = p.StandardError.ReadToEnd();

            if (!String.IsNullOrEmpty(errorMsg))
            {
                ExternalToolsManager.Log($"Error: {errorMsg}");
            }

            ExternalToolsManager.Log(outputBinary);
            p.StandardOutput.Close();
            p.StandardError.Close();
        }
 private void Download()
 {
     using (var client = new WebClient())
     {
         var logStr = $"... Downloading {ZipFileName} from {DownloadURL} to {TempDirectory}";
         Console.WriteLine(logStr); // until we have better verbosity
         ExternalToolsManager.Log(logStr);
         client.DownloadFile(DownloadURL, ZipFilePath);
     }
 }
        protected void DownloadAndCopy()
        {
            PrepareTempDirectory();
            Download();
            CopyToCommand(ZipFilePath);

            ExternalToolsManager.Log($"Cleaning up");
            File.Delete(ZipFilePath);
            ExternalToolsManager.Log($"Done");
        }
示例#5
0
 internal override void EnsureExisted()
 {
     EnsureCommandPathExisted();
     if (!Exists())
     {
         InstallDotnetCliTool();
     }
     else
     {
         ExternalToolsManager.Log($"Skip installing tool {this.settings.Name} as we could find it under {this.settings.CommandPath}.");
     }
 }
        protected void DownloadAndUnZip()
        {
            PrepareTempDirectory();
            Download();

            ExternalToolsManager.Log($"Extracting {ZipFileName} to {ExtractPath}");
            ZipFile.ExtractToDirectory(ZipFilePath, ExtractPath);

            CopyToCommand(ExeTempPath);

            ExternalToolsManager.Log($"Cleaning up");
            File.Delete(ZipFilePath);
            Directory.Delete(ExtractPath, true);
            ExternalToolsManager.Log($"Done");
        }
示例#7
0
        internal void EnsureLinkedToZ3(ToolManager z3)
        {
            var z3DependencyPath = GetZ3DependencyPath(z3);

            if (!File.Exists(z3DependencyPath))
            {
                ExternalToolsManager.Log($"Z3 does not exist under {this.settings.Name}");
                ExternalToolsManager.Log($"Copying {z3.Command} to {z3DependencyPath}");
                File.Copy(z3.Command, z3DependencyPath);
            }
            else
            {
                ExternalToolsManager.Log($"Z3 already exists under {this.settings.Name}");
                ExternalToolsManager.Log("Skip copying");
            }
        }
        private void DownloadedAndUnZip()
        {
            if (!Directory.Exists(TempDirectory))
            {
                ExternalToolsManager.Log($"Creating temporary directory {TempDirectory}");
                Directory.CreateDirectory(TempDirectory);
            }
            else
            {
                if (File.Exists(ZipFilePath))
                {
                    ExternalToolsManager.Log($"Deleting file {ZipFilePath}");
                    File.Delete(ZipFilePath);
                }

                if (Directory.Exists(ExtractPath))
                {
                    ExternalToolsManager.Log($"Deleting directory {ExtractPath}");
                    Directory.Delete(ExtractPath, true);
                }
            }

            using (var client = new WebClient())
            {
                ExternalToolsManager.Log($"Downloading {ZipFileName} from {DownloadURL} to {TempDirectory}");
                client.DownloadFile(DownloadURL, ZipFilePath);
            }

            ExternalToolsManager.Log($"Extracting {ZipFileName} to {ExtractPath}");
            ZipFile.ExtractToDirectory(ZipFilePath, ExtractPath);

            ExternalToolsManager.Log($"Copying {ExeTempPath} to {Command}");
            File.Copy(ExeTempPath, Command);

            ExternalToolsManager.Log($"Cleaning up");
            File.Delete(ZipFilePath);
            Directory.Delete(ExtractPath, true);
            ExternalToolsManager.Log($"Done");
        }
示例#9
0
        internal void EnsureLinkedToZ3(ToolManager z3)
        {
            var z3DependencyPath = GetZ3DependencyPath(z3);

            // Workaround: Boogie and Corral are looking for z3.exe, even on linux/mac
            if (!z3DependencyPath.EndsWith(".exe"))
            {
                z3DependencyPath += ".exe";
            }

            if (!File.Exists(z3DependencyPath))
            {
                ExternalToolsManager.Log($"Z3 does not exist under {this.settings.Name}");
                ExternalToolsManager.Log($"Copying {z3.Command} to {z3DependencyPath}");
                File.Copy(z3.Command, z3DependencyPath);
            }
            else
            {
                ExternalToolsManager.Log($"Z3 already exists under {this.settings.Name}");
                ExternalToolsManager.Log("Skip copying");
            }
        }
示例#10
0
        private void PrepareTempDirectory()
        {
            if (!Directory.Exists(TempDirectory))
            {
                ExternalToolsManager.Log($"Creating temporary directory {TempDirectory}");
                Directory.CreateDirectory(TempDirectory);
            }
            else
            {
                if (File.Exists(ZipFilePath))
                {
                    ExternalToolsManager.Log($"Deleting file {ZipFilePath}");
                    File.Delete(ZipFilePath);
                }

                if (Directory.Exists(ExtractPath))
                {
                    ExternalToolsManager.Log($"Deleting directory {ExtractPath}");
                    Directory.Delete(ExtractPath, true);
                }
            }
        }
示例#11
0
 private void CopyToCommand(string exeTempPath)
 {
     ExternalToolsManager.Log($"Copying {exeTempPath} to {Command}");
     File.Copy(exeTempPath, Command);
 }