private void OnInvokedDynamicItem(object sender, EventArgs e) { DynamicCommand invokedCommand = (DynamicCommand)sender; var commandConfig = this.configParser.Commands.Find(c => c.Title.Equals(invokedCommand.Text)); var currentProjectPath = VSHelpers.GetCurrentProjectPath(); var extentionPath = Path.GetDirectoryName(this.GetType().Assembly.Location); var exePath = Path.Combine(extentionPath, Constants.CLIFolderName, Constants.CLIName); var fileInfo = new FileInfo(exePath); if (!fileInfo.Exists) { string message = "File 'sf.exe' does not exist!"; VSHelpers.ShowErrorMessage(this, message, commandConfig.Title); return; } var args = String.Format("{0}", commandConfig.Name); // get arguments var dialog = new InputDialog(commandConfig); if (dialog.ShowDialog() == true) { for (int i = 0; i < dialog.ResponseText.Count; i++) { var input = dialog.ResponseText[i]; if (string.IsNullOrEmpty(input) || input.IndexOfAny(Path.GetInvalidFileNameChars()) > 0) { string message = string.Format("Invalid argument: {0}!", commandConfig.Args[i]); VSHelpers.ShowErrorMessage(this, message, commandConfig.Title); return; } // response is argument, else - response is option if (i < commandConfig.Args.Count) { args = String.Format("{0} \"{1}\"", args, input); } else { var optionIndex = i - commandConfig.Args.Count; args = String.Format("{0} {1} \"{2}\"", args, commandConfig.Options[optionIndex].Name, input); } } args = String.Format("{0} -r \"{1}\"", args, currentProjectPath); var process = new Process(); process.StartInfo.FileName = fileInfo.Name; process.StartInfo.WorkingDirectory = fileInfo.DirectoryName; process.StartInfo.Arguments = args; process.Start(); } }