private static string ProcessCommand(ExternalToolProperties readin, string tempToolPath, UnzipToolReturnAccumulator accumulator) { string command = readin.Command.Trim(); var programPathContainer = ToolMacros.GetProgramPathContainer(command); if (!ToolDescription.IsWebPageCommand(command) && programPathContainer == null) { // ReSharper disable once LocalizableElement if (command.StartsWith(ToolMacros.TOOL_DIR + "\\")) { command = command.Substring(ToolMacros.TOOL_DIR.Length + 1); } if (!File.Exists(Path.Combine(tempToolPath, command))) { accumulator.AddMessage(string.Format(Resources.ToolInstaller_AddToolFromProperties_Missing_the_file__0___Tool__1__import_failed, command, readin.Title)); return(null); } command = Path.Combine(ToolMacros.TOOL_DIR, command); } else if (programPathContainer != null) // If it is a ProgramPath macro { FindPackagesToInstall(readin, accumulator, programPathContainer); } return(command); }
private static string ProcessCommand(ExternalToolProperties readin, string tempToolPath, UnzipToolReturnAccumulator accumulator) { string command = readin.Command.Trim(); var programPathContainer = ToolMacros.GetProgramPathContainer(command); if (!ToolDescription.IsWebPageCommand(command) && programPathContainer == null) { if (command.StartsWith(ToolMacros.TOOL_DIR + "\\")) // Not L10N { command = command.Substring(ToolMacros.TOOL_DIR.Length + 1); } if (!File.Exists(Path.Combine(tempToolPath, command))) { accumulator.AddMessage(string.Format(Resources.ToolInstaller_AddToolFromProperties_Missing_the_file__0___Tool__1__import_failed, command, readin.Title)); return null; } command = Path.Combine(ToolMacros.TOOL_DIR, command); } else if (programPathContainer != null) // If it is a ProgramPath macro { FindPackagesToInstall(readin, accumulator, programPathContainer); } return command; }
private static void AddToolFromProperties(FileInfo file, UnzipToolReturnAccumulator accumulator, ToolInfo toolInfo, string placeHolderToolPath, string tempToolPath, IDictionary <string, string> reportRenameMapping) { if (file.Name == INFO_PROPERTIES) { return; } ExternalToolProperties readin; try { readin = new ExternalToolProperties(file.FullName); } catch (Exception) { //Failed to read the .properties file accumulator.AddMessage(string.Format(Resources.ConfigureToolsDlg_unpackZipTool_Failed_to_process_file_0_The_tool_described_failed_to_import, file.Name)); return; } if (readin.Title == null || readin.Command == null) { accumulator.AddMessage(string.Format(TextUtil.LineSeparate( Resources.ConfigureToolsDlg_unpackZipTool_Invalid_Tool_Description_in_file__0__, Resources.ConfigureToolsDlg_unpackZipTool_Title_and_Command_are_required, Resources.ConfigureToolsDlg_unpackZipTool_skipping_that_tool_), file.Name)); return; } string command = ProcessCommand(readin, tempToolPath, accumulator); if (string.IsNullOrEmpty(command)) { return; } string reportTitle = readin.Input_Report_Name; List <AnnotationDef> annotations = new List <AnnotationDef>(); // Check we have the relevant report if (!string.IsNullOrWhiteSpace(reportTitle)) { if (reportRenameMapping.ContainsKey(reportTitle)) { //Apply report renaming if install in parallel was selectedd reportTitle = reportRenameMapping[reportTitle]; } // Check if they are still missing the report they want if (!ReportSharing.GetExistingReports().ContainsKey(PersistedViews.ExternalToolsGroup.Id.ViewName(reportTitle))) { accumulator.AddMessage(string.Format(Resources.UnpackZipToolHelper_UnpackZipTool_The_tool___0___requires_report_type_titled___1___and_it_is_not_provided__Import_canceled_, readin.Title, reportTitle)); return; } // Get annotations for this specific tool GetAnotations(readin, annotations); } //Check the ArgsCollector Dll exists. string dllPath = readin.Args_Collector_Dll; if (!string.IsNullOrEmpty(dllPath)) { // Handle case where they prepended the DllPath with $(ToolDir)\\. // ReSharper disable once LocalizableElement if (dllPath.StartsWith(ToolMacros.TOOL_DIR + "\\")) { dllPath = dllPath.Substring(ToolMacros.TOOL_DIR.Length + 1); } if (!File.Exists(Path.Combine(tempToolPath, dllPath))) { accumulator.AddMessage(string.Format(Resources.ToolInstaller_AddToolFromProperties_Missing_the_file__0___Tool__1__import_failed, dllPath, readin.Title)); return; } // Path to the dll gets renamed at the end of the UnpackZipTools Function when we // finally decide the directory for the $(ToolDir) } //Make sure tools get a unique title. string uniqueTitle = GetUniqueToolTitle(readin.Title); //Append each tool to the return value accumulator.AddTool(new ToolDescription(uniqueTitle, command, readin.Arguments, readin.Initial_Directory, readin.Output_to_Immediate_Window.Contains(@"True"), reportTitle, dllPath, readin.Args_Collector_Type, placeHolderToolPath, annotations, toolInfo.PackageVersion, toolInfo.PackageIdentifier, toolInfo.PackageName)); }
private static void AddToolFromProperties(FileInfo file, UnzipToolReturnAccumulator accumulator, ToolInfo toolInfo, string placeHolderToolPath, string tempToolPath, IDictionary<string, string> reportRenameMapping) { if (file.Name == INFO_PROPERTIES) return; ExternalToolProperties readin; try { readin = new ExternalToolProperties(file.FullName); } catch (Exception) { //Failed to read the .properties file accumulator.AddMessage(string.Format(Resources.ConfigureToolsDlg_unpackZipTool_Failed_to_process_file_0_The_tool_described_failed_to_import, file.Name)); return; } if (readin.Title == null || readin.Command == null) { accumulator.AddMessage(string.Format(TextUtil.LineSeparate( Resources.ConfigureToolsDlg_unpackZipTool_Invalid_Tool_Description_in_file__0__, Resources.ConfigureToolsDlg_unpackZipTool_Title_and_Command_are_required, Resources.ConfigureToolsDlg_unpackZipTool_skipping_that_tool_), file.Name)); return; } string command = ProcessCommand(readin, tempToolPath, accumulator); if (string.IsNullOrEmpty(command)) return; string reportTitle = readin.Input_Report_Name; List<AnnotationDef> annotations = new List<AnnotationDef>(); // Check we have the relevant report if (!string.IsNullOrWhiteSpace(reportTitle)) { if (reportRenameMapping.ContainsKey(reportTitle)) { //Apply report renaming if install in parallel was selectedd reportTitle = reportRenameMapping[reportTitle]; } // Check if they are still missing the report they want if (!ReportSharing.GetExistingReports().ContainsKey(PersistedViews.ExternalToolsGroup.Id.ViewName(reportTitle))) { accumulator.AddMessage(string.Format(Resources.UnpackZipToolHelper_UnpackZipTool_The_tool___0___requires_report_type_titled___1___and_it_is_not_provided__Import_canceled_, readin.Title, reportTitle)); return; } // Get annotations for this specific tool GetAnotations(readin, annotations); } //Check the ArgsCollector Dll exists. string dllPath = readin.Args_Collector_Dll; if (!string.IsNullOrEmpty(dllPath)) { // Handle case where they prepended the DllPath with $(ToolDir)\\. if (dllPath.StartsWith(ToolMacros.TOOL_DIR + "\\")) // Not L10N { dllPath = dllPath.Substring(ToolMacros.TOOL_DIR.Length + 1); } if (!File.Exists(Path.Combine(tempToolPath, dllPath))) { accumulator.AddMessage(string.Format(Resources.ToolInstaller_AddToolFromProperties_Missing_the_file__0___Tool__1__import_failed, dllPath, readin.Title)); return; } // Path to the dll gets renamed at the end of the UnpackZipTools Function when we // finally decide the directory for the $(ToolDir) } //Make sure tools get a unique title. string uniqueTitle = GetUniqueToolTitle(readin.Title); //Append each tool to the return value accumulator.AddTool(new ToolDescription(uniqueTitle, command, readin.Arguments, readin.Initial_Directory, readin.Output_to_Immediate_Window.Contains("True"), // Not L10N reportTitle, dllPath, readin.Args_Collector_Type, placeHolderToolPath, annotations, toolInfo.PackageVersion, toolInfo.PackageIdentifier, toolInfo.PackageName)); }