static void Main(string[] args) { Console.WriteLine("Press Enter to continue.."); Console.ReadLine(); Shared.Client.Client client = new Shared.Client.Client("127.0.0.1", Server.ServicePort); ExecutionParameters parameters = new ExecutionParameters(); parameters.ExecutionCommand = "run"; parameters.Command = Command.DebugContent; parameters.ProjectPath = "src\\helloWorld.Console\\helloWorld.Console.xproj"; parameters.Payload = File.ReadAllBytes("helloWorld.zip"); client.Send(parameters); }
/// <summary> /// This function is the callback used to execute the command when the menu item is clicked. /// See the constructor to see how the menu item is associated with this function using /// OleMenuCommandService service and MenuCommand class. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event args.</param> private void MenuItemCallback(object sender, EventArgs e) { GetActiveIde().ExecuteCommand("File.SaveAll"); var projects = GetProjects().Select(p => new ProjectDefinition() { Name = p.Name, Path = p.UniqueName }).ToList(); var viewModel = new ProjectSelectorViewModel(); viewModel.Projects = projects; DebugDefinition debugDefinition = null; using (ProjectSelector ps = new ProjectSelector(viewModel)) { if (ps.ShowDialog().GetValueOrDefault(false)) { debugDefinition = ps.DebugDefinition; } } if (debugDefinition != null) { var solution = GetSolution(); var tempFile = Path.Combine(Path.GetTempPath(), string.Format("{0}.zip", Path.GetFileName(solution.FileName))); if (File.Exists(tempFile)) { File.Delete(tempFile); } //Test Endpoint //Package Solution ZipFile.CreateFromDirectory(Path.GetDirectoryName(solution.FullName), tempFile); ExecutionParameters parameters = new ExecutionParameters(); parameters.Command = Command.DebugContent; parameters.ProjectPath = debugDefinition.Project.Path; parameters.ExecutionCommand = debugDefinition.Command; parameters.Payload = File.ReadAllBytes(tempFile); Shared.Client.Client client = new Shared.Client.Client(debugDefinition.Endpoint, Server.ServicePort); client.Send(parameters); client.WaitForAnswer(); //Transmit Package var dte = (DTE)Package.GetGlobalService(typeof(DTE)); IntPtr pInfo = GetDebugInfo(debugDefinition.Endpoint, debugDefinition.Project.Path, debugDefinition.Project.Path); var sp = new ServiceProvider((Microsoft.VisualStudio.OLE.Interop.IServiceProvider)dte); try { var dbg = (IVsDebugger)sp.GetService(typeof(SVsShellDebugger)); int hr = dbg.LaunchDebugTargets(1, pInfo); Marshal.ThrowExceptionForHR(hr); DebuggedProcess.Instance.AssociateDebugSession(client); } catch (Exception ex) { //logger.Error(ex); string msg; var sh = (IVsUIShell)sp.GetService(typeof(SVsUIShell)); sh.GetErrorInfo(out msg); if (!string.IsNullOrWhiteSpace(msg)) { //logger.Error(msg); } throw; } finally { if (pInfo != IntPtr.Zero) { Marshal.FreeCoTaskMem(pInfo); } } } //string message = string.Format(CultureInfo.CurrentCulture, "Inside {0}.MenuItemCallback()", this.GetType().FullName); //string title = "AttachDebuggerCommand"; //// Show a message box to prove we were here //VsShellUtilities.ShowMessageBox( // this.ServiceProvider, // message, // title, // OLEMSGICON.OLEMSGICON_INFO, // OLEMSGBUTTON.OLEMSGBUTTON_OK, // OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST); }