public /*override*/ int LaunchSuspended(string pszServer, IDebugPort2 pPort, string pszExe, string pszArgs, string pszDir, string bstrEnv, string pszOptions, enum_LAUNCH_FLAGS dwLaunchFlags, uint hStdInput, uint hStdOutput, uint hStdError, IDebugEventCallback2 pCallback, out IDebugProcess2 ppProcess) { NLogService.TraceEnteringMethod(); var base64Options = SerializeDebuggerOptions(pszOptions); var result = _engine.LaunchSuspended(pszServer, pPort, pszExe, pszArgs, pszDir, bstrEnv, base64Options, dwLaunchFlags, hStdInput, hStdOutput, hStdError, pCallback, out ppProcess); return(result); }
private string SerializeDebuggerOptions(string jsonDebugOptions) { try { NLogService.TraceEnteringMethod(Logger); var debugOptions = DebugOptions.DeserializeFromJson(jsonDebugOptions); _session = new MonoDebugSession(); LogMonoDebuggerAssemblyPaths(); if (debugOptions.UserSettings.EnableVerboseDebugLogging) { RegisterEventHandlers(); } var connectionTimeout = 30000; var evaluationTimeout = 30000; var startupProject = StartupProject; XamarinEngine.DebugOptions = debugOptions; var softDebuggerConnectArgs = new SoftDebuggerConnectArgs(debugOptions.TargetExeFileName, debugOptions.GetHostIP(), debugOptions.GetMonoDebugPort()); // TODO implement programm output via stream //softDebuggerConnectArgs.RedirectOutput = true; //softDebuggerConnectArgs.OutputPort = ???; //_session.VirtualMachine.StandardOutput ??? softDebuggerConnectArgs.TimeBetweenConnectionAttempts = (int)debugOptions.UserSettings.TimeBetweenConnectionAttemptsInMs; softDebuggerConnectArgs.MaxConnectionAttempts = (int)debugOptions.UserSettings.MaxConnectionAttempts; _startInfo = new StartInfo( softDebuggerConnectArgs, new DebuggingOptions() { EvaluationTimeout = evaluationTimeout, MemberEvaluationTimeout = evaluationTimeout, ModificationTimeout = evaluationTimeout, SocketTimeout = connectionTimeout }, startupProject ); SessionMarshalling sessionMarshalling = new SessionMarshalling(_session, _startInfo); using (MemoryStream ms = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); ObjRef oref = RemotingServices.Marshal(sessionMarshalling); bf.Serialize(ms, oref); return(Convert.ToBase64String(ms.ToArray())); } } catch (Exception ex) { Logger.Error(ex); throw; } }
public void Send(byte[] Data) { NLogService.TraceEnteringMethod(Logger); this.ReconnectCurrentCount = 0; lock (LockObject) { WaittingToSendDatas.AddLast(Data); } }
private void Clear() { NLogService.TraceEnteringMethod(Logger); // this.WaittingToSendDatas.Clear(); if (this.Client != null) { this.Client.Close(); this.Client = null; } }
public bool IsStartupProjectAvailable() { NLogService.TraceEnteringMethod(); ThreadHelper.ThrowIfNotOnUIThread(); var sb = (SolutionBuild2)_dte.Solution.SolutionBuild; return(sb.StartupProjects != null && ((Array)sb.StartupProjects).Cast <string>().Count() > 0); }
private int BuildSolution() { NLogService.TraceEnteringMethod(Logger); ThreadHelper.ThrowIfNotOnUIThread(); var sb = (SolutionBuild2)_dte.Solution.SolutionBuild; sb.Build(true); return(sb.LastBuildInfo); }
public async Task OverrideRunCommandAsync() { NLogService.TraceEnteringMethod(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); // https://stackoverflow.com/questions/15908652/how-to-programmatically-override-the-build-and-launch-actions // https://visualstudioextensions.vlasovstudio.com/2017/06/29/changing-visual-studio-2017-private-registry-settings/ // https://github.com/3F/vsCommandEvent var _dteEvents = _dte.Events; _startCommandEvents = _dte.Events.CommandEvents["{5EFC7975-14BC-11CF-9B2B-00AA00573819}", 295]; _startCommandEvents.BeforeExecute += OnBeforeStartCommand; }
public /*override*/ int Attach(IDebugProgram2[] rgpPrograms, IDebugProgramNode2[] rgpProgramNodes, uint celtPrograms, IDebugEventCallback2 pCallback, enum_ATTACH_REASON dwReason) { NLogService.TraceEnteringMethod(); try { _session.Run(_startInfo, _startInfo.SessionOptions); } catch (Exception ex) { Debug.WriteLine(ex.Message + " - " + ex.StackTrace); } return(_engine.Attach(rgpPrograms, rgpProgramNodes, celtPrograms, pCallback, dwReason)); }
public void AttachDebuggerToRunningProcess(DebugOptions debugOptions) { NLogService.TraceEnteringMethod(); ThreadHelper.ThrowIfNotOnUIThread(); if (DebugEngineGuids.UseAD7Engine == EngineType.XamarinEngine) { // Workaround to get StartProject XamarinEngine.StartupProject = GetStartupProject(); } IntPtr pInfo = GetDebugInfo(debugOptions); var sp = new ServiceProvider((IServiceProvider)_dte); try { var dbg = sp.GetService(typeof(SVsShellDebugger)) as IVsDebugger; if (dbg == null) { logger.Error($"GetService did not returned SVsShellDebugger"); } int hr = dbg.LaunchDebugTargets(1, pInfo); Marshal.ThrowExceptionForHR(hr); } catch (Exception ex) { logger.Error(ex); string msg = null; var sh = sp.GetService(typeof(SVsUIShell)) as IVsUIShell; if (sh != null) { sh.GetErrorInfo(out msg); } if (!string.IsNullOrWhiteSpace(msg)) { logger.Error(msg); } throw; } finally { if (pInfo != IntPtr.Zero) { Marshal.FreeCoTaskMem(pInfo); } } }
private Task <bool> StartDebuggerAsync(SshDeltaCopy.Options options, DebugOptions debugOptions, bool deploy, bool debug, Func <string, Task> writeOutput, RedirectOutputOptions redirectOutputOption) { NLogService.TraceEnteringMethod(Logger); return(Task.Run <bool>(async() => { var errorHelpText = new StringBuilder(); Action <string> writeLineOutput = s => writeOutput(s + Environment.NewLine).Wait(); try { errorHelpText.AppendLine($"SSH Login: {options.Username}@{options.Host}:{options.Port} Directory: {options.DestinationDirectory}"); using (SshDeltaCopy sshDeltaCopy = new SshDeltaCopy(options)) { sshDeltaCopy.LogOutput = writeLineOutput; if (deploy) { Logger.Info($"StartDebuggerAsync - deploy"); errorHelpText.AppendLine($"SSH: Start deployment from '{options.SourceDirectory}' to '{options.DestinationDirectory}'."); sshDeltaCopy.DeployDirectory(options.SourceDirectory, options.DestinationDirectory); errorHelpText.AppendLine($"SSH Deployment was successful."); // We are creating mdb files on local machine with pdb2mdb //var createMdbCommand = sshDeltaCopy.RunSSHCommand($@"find . -regex '.*\(exe\|dll\)' -exec {debugOptions.UserSettings.SSHPdb2mdbCommand} {{}} \;", false); //msgOutput(createMdbCommand.Result); } if (debug) { Logger.Info($"StartDebuggerAsync - debug"); await DebugAsync(debugOptions, writeOutput, redirectOutputOption, errorHelpText, writeLineOutput, sshDeltaCopy); } } } catch (Exception ex) { var additionalErrorMessage = $"SSHDebugger: {ex.Message}\n\nExecuted steps:\n{errorHelpText.ToString()}"; await writeOutput(additionalErrorMessage); throw new Exception(additionalErrorMessage, ex); } return true; })); }
public async Task BuildStartupProjectAsync() { NLogService.TraceEnteringMethod(); await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); var failedBuilds = BuildStartupProject(); if (failedBuilds > 0) { Window window = _dte.Windows.Item("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}");//EnvDTE.Constants.vsWindowKindOutput OutputWindow outputWindow = (OutputWindow)window.Object; outputWindow.ActivePane.Activate(); outputWindow.ActivePane.OutputString($"{failedBuilds} project(s) failed to build. See error and output window!"); _errorListProvider.Show(); throw new Exception($"{failedBuilds} project(s) failed to build. See error and output window!"); } }
public void AttachDotnetDebuggerToRunningProcess(DebugOptions debugOptions) { NLogService.TraceEnteringMethod(Logger); var extensionInstallationDirectory = GetExtensionInstallationDirectoryOrNull(); if (extensionInstallationDirectory == null) { Logger.Error($"{nameof(extensionInstallationDirectory)} is null!"); } var settings = debugOptions.UserSettings; var launchJson = settings.LaunchJsonContent; var jsonStringPlinkExe = JsonConvert.SerializeObject(Path.Combine(extensionInstallationDirectory, "plink.exe")).Trim('"'); launchJson = launchJson.Replace(settings.PLINK_EXE_PATH, jsonStringPlinkExe); var sshPassword = string.IsNullOrWhiteSpace(settings.SSHPrivateKeyFile) ? $"-pw {settings.SSHPassword} {settings.SSHFullUrl}" : $"-i {settings.SSHPrivateKeyFile} {settings.SSHFullUrl}"; launchJson = launchJson.Replace(settings.PLINK_SSH_CONNECTION_ARGS, $"{sshPassword} "); var jsonStringDeployPath = JsonConvert.SerializeObject(debugOptions.UserSettings.SSHDeployPath).Trim('"'); launchJson = launchJson.Replace(settings.DEPLOYMENT_PATH, jsonStringDeployPath); launchJson = launchJson.Replace(settings.TARGET_EXE_FILENAME, debugOptions.TargetExeFileName); var jsonStringStartArguments = JsonConvert.SerializeObject(debugOptions.StartArguments).Trim('"'); launchJson = launchJson.Replace(settings.START_ARGUMENTS, jsonStringStartArguments); string launchJsonFile = Path.Combine(GetStartupProjectPath(), "launch.json"); Logger.Info($"Path of launch.json = {launchJsonFile}"); File.WriteAllText(launchJsonFile, launchJson); Logger.Info($"Project {debugOptions.StartupAssemblyPath} was built successfully. Invoking remote debug command"); var dte2 = _dte as DTE2; dte2.ExecuteCommand("DebugAdapterHost.Launch", $"/LaunchJson:\"{launchJsonFile}\" /EngineGuid:541B8A8A-6081-4506-9F0A-1CE771DEBC04"); }
public /*override*/ int ContinueFromSynchronousEvent(IDebugEvent2 pEvent) { NLogService.TraceEnteringMethod(); return(_engine.ContinueFromSynchronousEvent(pEvent)); }
public /*override*/ int SetLocale(ushort wLangID) { NLogService.TraceEnteringMethod(); return(_engine.SetLocale(wLangID)); }
public Task <bool> RunAndDebugAsync(DebugOptions debugOptions, Func <string, Task> writeOutput, RedirectOutputOptions redirectOutputOption = RedirectOutputOptions.None) { NLogService.TraceEnteringMethod(Logger); writeOutput("Start RunAndDebug over SSH ..."); return(StartDebuggerAsync(_sshOptions, debugOptions, false, true, writeOutput, redirectOutputOption)); }
private Task <bool> StartDebuggerAsync(DebugOptions debugOptions, bool deploy, bool debug, Func <string, Task> writeOutput, RedirectOutputOptions redirectOutputOption) { NLogService.TraceEnteringMethod(Logger); return(Task.Run <bool>(async() => { var errorHelpText = new StringBuilder(); Action <string> writeLineOutput = s => writeOutput(s + Environment.NewLine).Wait(); try { var destinationDirectory = debugOptions.UserSettings.WindowsDeployPath; if (string.IsNullOrWhiteSpace(destinationDirectory)) { destinationDirectory = debugOptions.OutputDirectory; } else if (!Path.IsPathRooted(destinationDirectory)) { destinationDirectory = Path.Combine(debugOptions.OutputDirectory, destinationDirectory); } errorHelpText.AppendLine($"Directory: {destinationDirectory}"); if (deploy) { Logger.Info($"StartDebuggerAsync - deploy"); errorHelpText.AppendLine($"Local: Start deployment from '{debugOptions.OutputDirectory}' to '{destinationDirectory}'."); Directory.CreateDirectory(destinationDirectory); DirectoryCopy(debugOptions.OutputDirectory, destinationDirectory, copySubDirs: true, overwrite: true, writeOutput: writeOutput); errorHelpText.AppendLine($"Local Deployment was successful."); } if (debug) { Logger.Info($"StartDebuggerAsync - debug"); var killCommandText = debugOptions.PreDebugScript; errorHelpText.AppendLine($"Local: Stop previous mono processes with the PreDebugScript"); errorHelpText.AppendLine(killCommandText); Logger.Info($"Run PreDebugScript: {killCommandText}"); PowershellExecuter.RunScript(killCommandText, destinationDirectory, writeLineOutput, redirectOutputOption); // TODO //if (killCommand.ExitStatus != 0 || !string.IsNullOrWhiteSpace(killCommand.Error)) //{ // var error = $"SSH script error in PreDebugScript:\n{killCommand.CommandText}\n{killCommand.Error}"; // //errorHelpText.AppendLine(error); // Logger.Error(error); //} var monoDebugCommand = debugOptions.DebugScript; errorHelpText.AppendLine($"Local: Start mono debugger"); errorHelpText.AppendLine(monoDebugCommand); Logger.Info($"Run DebugScript: {monoDebugCommand}"); // TODO if DebugScript fails no error is shown - very bad! await writeOutput(errorHelpText.ToString()); PowershellExecuter.RunScript(monoDebugCommand, destinationDirectory, writeLineOutput, redirectOutputOption); // TODO //await RunCommandAndRedirectOutputAsync(cmd, writeOutput, redirectOutputOption); //if (cmd.ExitStatus != 0 || !string.IsNullOrWhiteSpace(cmd.Error)) //{ // var error = $"SSH script error in DebugScript:\n{cmd.CommandText}\n{cmd.Error}"; // //errorHelpText.AppendLine(error); // Logger.Error(error); // throw new Exception(error); //} } } catch (Exception ex) { var additionalErrorMessage = $"SSHDebugger: {ex.Message}\n\nExecuted steps:\n{errorHelpText.ToString()}"; await writeOutput(additionalErrorMessage); throw new Exception(additionalErrorMessage, ex); } return true; })); }
public Task <bool> DeployAsync(DebugOptions debugOptions, Func <string, Task> writeOutput, RedirectOutputOptions redirectOutputOption = RedirectOutputOptions.None) { NLogService.TraceEnteringMethod(Logger); writeOutput("Start Deploy locally ..."); return(StartDebuggerAsync(debugOptions, true, false, writeOutput, redirectOutputOption)); }
public /*override*/ int CauseBreak() { NLogService.TraceEnteringMethod(); return(_engine.CauseBreak()); }
private void OnBeforeStartCommand(string guid, int id, object customIn, object customOut, ref bool cancelDefault) { NLogService.TraceEnteringMethod(); //your event handler this command }
public void OverwriteWithProjectSettingsFromStartupProject(ref UserSettings globalSettings) { NLogService.TraceEnteringMethod(Logger); try { ThreadHelper.ThrowIfNotOnUIThread(); var startupProject = GetStartupProject(); var projectFullName = startupProject.FullName; if (File.Exists(projectFullName)) { var name = Path.GetFileNameWithoutExtension(projectFullName); var dir = Path.GetDirectoryName(projectFullName); var configFiles = new string[] { Path.Combine(dir, name + ".VSMonoDebugger.config"), Path.Combine(dir, "VSMonoDebugger.config"), Path.Combine(dir, "VSMonoDebugger.json"), }; var projectConfigFile = configFiles.FirstOrDefault(x => File.Exists(x)); if (projectConfigFile == null) { Logger.Info($"Local project config file not found."); } else { try { Logger.Info($"Local project config file {projectConfigFile} found."); var projectConfigFileContent = File.ReadAllText(projectConfigFile); var projectSettingsByString = JsonConvert.DeserializeObject(projectConfigFileContent) as IDictionary <string, Newtonsoft.Json.Linq.JToken>; var globalSettingsByString = JsonConvert.DeserializeObject(JsonConvert.SerializeObject(globalSettings)) as IDictionary <string, Newtonsoft.Json.Linq.JToken>; foreach (var projectKeyValue in projectSettingsByString) { if (globalSettingsByString.TryGetValue(projectKeyValue.Key, out Newtonsoft.Json.Linq.JToken globalSettingsValue) && projectKeyValue.Value.Type == globalSettingsValue.Type) { Logger.Info($"Setting {projectKeyValue.Key} was overwritten with local project file: {globalSettingsValue.ToString()} => {projectKeyValue.Value.ToString()}"); globalSettingsByString[projectKeyValue.Key] = projectKeyValue.Value; } } globalSettings = JsonConvert.DeserializeObject <UserSettings>(JsonConvert.SerializeObject(globalSettingsByString)); } catch (Exception ex) { // *.VSMonoDebugger.config can contain illigal escape characters for WindowsPath "C:\Temp" => "C:\\Temp" // Don't fix it ... user has to be json conform Logger.Info("Please validate that the local project config file {projectConfigFile} conatins no illigal escape character sequences for WindowsDeployPath!"); NLogService.LogError(Logger, ex); } } } } catch (Exception ex2) { NLogService.LogError(Logger, ex2); } }
public /*override*/ int RemoveSetException(EXCEPTION_INFO[] pException) { NLogService.TraceEnteringMethod(); return(_engine.RemoveSetException(pException)); }
private Task <bool> StartDebuggerAsync(SshDeltaCopy.Options options, DebugOptions debugOptions, bool deploy, bool debug, Func <string, Task> writeOutput, RedirectOutputOptions redirectOutputOption) { NLogService.TraceEnteringMethod(); return(Task.Run <bool>(async() => { var errorHelpText = new StringBuilder(); Action <string> writeLineOutput = s => writeOutput(s + Environment.NewLine).Wait(); try { errorHelpText.AppendLine($"SSH Login: {options.Username}@{options.Host}:{options.Port} Directory: {options.DestinationDirectory}"); using (SshDeltaCopy sshDeltaCopy = new SshDeltaCopy(options)) { sshDeltaCopy.LogOutput = writeLineOutput; if (deploy) { NLogService.Logger.Info($"StartDebuggerAsync - deploy"); errorHelpText.AppendLine($"SSH: Start deployment from '{options.SourceDirectory}' to '{options.DestinationDirectory}'."); sshDeltaCopy.DeployDirectory(options.SourceDirectory, options.DestinationDirectory); errorHelpText.AppendLine($"SSH Deployment was successful."); // We are creating mdb files on local machine with pdb2mdb //var createMdbCommand = sshDeltaCopy.RunSSHCommand($@"find . -regex '.*\(exe\|dll\)' -exec {debugOptions.UserSettings.SSHPdb2mdbCommand} {{}} \;", false); //msgOutput(createMdbCommand.Result); } if (debug) { NLogService.Logger.Info($"StartDebuggerAsync - debug"); errorHelpText.AppendLine($"SSH: Stop previous mono processes."); var killCommandText = debugOptions.PreDebugScript; var killCommand = sshDeltaCopy.RunSSHCommand(killCommandText, false); writeLineOutput(killCommand.Result); NLogService.Logger.Info($"Run PreDebugScript: {killCommandText}"); if (killCommand.ExitStatus != 0 || !string.IsNullOrWhiteSpace(killCommand.Error)) { var error = $"SSH script error in PreDebugScript:\n{killCommand.CommandText}\n{killCommand.Error}"; //errorHelpText.AppendLine(error); NLogService.Logger.Error(error); } var monoDebugCommand = debugOptions.DebugScript; errorHelpText.AppendLine($"SSH: Start mono debugger"); errorHelpText.AppendLine(monoDebugCommand); NLogService.Logger.Info($"Run DebugScript: {monoDebugCommand}"); // TODO if DebugScript fails no error is shown - very bad! await writeOutput(errorHelpText.ToString()); var cmd = sshDeltaCopy.CreateSSHCommand(monoDebugCommand); await RunCommandAndRedirectOutputAsync(cmd, writeOutput, redirectOutputOption); if (cmd.ExitStatus != 0 || !string.IsNullOrWhiteSpace(cmd.Error)) { var error = $"SSH script error in DebugScript:\n{cmd.CommandText}\n{cmd.Error}"; //errorHelpText.AppendLine(error); NLogService.Logger.Error(error); throw new Exception(error); } //var monoDebugCommandResult = await Task.Factory.FromAsync(cmd.BeginExecute(), result => cmd.Result); //msgOutput(monoDebugCommandResult); } } } catch (Exception ex) { var additionalErrorMessage = $"SSHDebugger: {ex.Message}\n\nExecuted steps:\n{errorHelpText.ToString()}"; await writeOutput(additionalErrorMessage); throw new Exception(additionalErrorMessage, ex); } return true; })); }
public /*override*/ int EnumPrograms(out IEnumDebugPrograms2 ppEnum) { NLogService.TraceEnteringMethod(); return(_engine.EnumPrograms(out ppEnum)); }
public /*override*/ int SetRegistryRoot(string pszRegistryRoot) { NLogService.TraceEnteringMethod(); return(_engine.SetRegistryRoot(pszRegistryRoot)); }
private string SerializeDebuggerOptions(string jsonDebugOptions) { try { NLogService.TraceEnteringMethod(); var debugOptions = DebugOptions.DeserializeFromJson(jsonDebugOptions); _session = new SoftDebuggerSession(); _session.TargetReady += (sender, eventArgs) => { Debug.WriteLine("TargetReady!"); }; _session.ExceptionHandler = exception => true; _session.TargetExited += (sender, x) => { Debug.WriteLine("TargetExited!"); }; _session.TargetUnhandledException += (sender, x) => { Debug.WriteLine("TargetUnhandledException!"); }; _session.LogWriter = (stderr, text) => Debug.WriteLine(text); _session.OutputWriter = (stderr, text) => Debug.WriteLine(text); _session.TargetThreadStarted += (sender, x) => Debug.WriteLine("TargetThreadStarted!"); _session.TargetThreadStopped += (sender, x) => { Debug.WriteLine("TargetThreadStopped!"); }; _session.TargetStopped += (sender, x) => Debug.WriteLine(x.Type); _session.TargetStarted += (sender, x) => Debug.WriteLine("TargetStarted"); _session.TargetSignaled += (sender, x) => Debug.WriteLine(x.Type); _session.TargetInterrupted += (sender, x) => Debug.WriteLine(x.Type); _session.TargetExceptionThrown += (sender, x) => { Debug.WriteLine("TargetExceptionThrown!"); }; _session.TargetHitBreakpoint += (sender, x) => { Debug.WriteLine("TargetHitBreakpoint!"); }; _session.TargetEvent += _session_TargetEvent; var connectionTimeout = 30000; var evaluationTimeout = 30000; var startupProject = StartupProject; var softDebuggerConnectArgs = new SoftDebuggerConnectArgs(debugOptions.TargetExeFileName, debugOptions.GetHostIP(), debugOptions.GetMonoDebugPort()); // TODO implement programm output via stream //softDebuggerConnectArgs.RedirectOutput = true; //softDebuggerConnectArgs.OutputPort = ???; //_session.VirtualMachine.StandardOutput ??? softDebuggerConnectArgs.TimeBetweenConnectionAttempts = (int)debugOptions.UserSettings.TimeBetweenConnectionAttemptsInMs; softDebuggerConnectArgs.MaxConnectionAttempts = (int)debugOptions.UserSettings.MaxConnectionAttempts; _startInfo = new StartInfo( softDebuggerConnectArgs, new DebuggingOptions() { EvaluationTimeout = evaluationTimeout, MemberEvaluationTimeout = evaluationTimeout, ModificationTimeout = evaluationTimeout, SocketTimeout = connectionTimeout }, startupProject ); SessionMarshalling sessionMarshalling = new SessionMarshalling(_session, _startInfo); using (MemoryStream ms = new MemoryStream()) { BinaryFormatter bf = new BinaryFormatter(); ObjRef oref = RemotingServices.Marshal(sessionMarshalling); bf.Serialize(ms, oref); return(Convert.ToBase64String(ms.ToArray())); } } catch (Exception ex) { NLogService.Logger.Error(ex); throw; } }
public /*override*/ int DestroyProgram(IDebugProgram2 pProgram) { NLogService.TraceEnteringMethod(); return(_engine.DestroyProgram(pProgram)); }
public /*override*/ int RemoveAllSetExceptions(ref Guid guidType) { NLogService.TraceEnteringMethod(); return(_engine.RemoveAllSetExceptions(ref guidType)); }
/// <summary> /// We don't want to create a launch.json file /// Currently not working! /// </summary> /// <param name="debugOptions"></param> internal void AttachDotnetDebuggerToRunningProcess2(DebugOptions debugOptions) { NLogService.TraceEnteringMethod(Logger); ThreadHelper.ThrowIfNotOnUIThread(); var extensionInstallationDirectory = GetExtensionInstallationDirectoryOrNull(); if (extensionInstallationDirectory == null) { Logger.Error($"{nameof(extensionInstallationDirectory)} is null!"); } var settings = debugOptions.UserSettings; var launchJson = settings.LaunchJsonContent; var jsonStringPlinkExe = JsonConvert.SerializeObject(Path.Combine(extensionInstallationDirectory, "plink.exe")).Trim('"'); launchJson = launchJson.Replace(settings.PLINK_EXE_PATH, jsonStringPlinkExe); var sshPassword = string.IsNullOrWhiteSpace(settings.SSHPrivateKeyFile) ? $"-pw {settings.SSHPassword} {settings.SSHFullUrl}" : $"-i {settings.SSHPrivateKeyFile} {settings.SSHFullUrl}"; launchJson = launchJson.Replace(settings.PLINK_SSH_CONNECTION_ARGS, $"{sshPassword} "); var jsonStringDeployPath = JsonConvert.SerializeObject(debugOptions.UserSettings.SSHDeployPath).Trim('"'); launchJson = launchJson.Replace(settings.DEPLOYMENT_PATH, jsonStringDeployPath); launchJson = launchJson.Replace(settings.TARGET_EXE_FILENAME, debugOptions.TargetExeFileName); var jsonStringStartArguments = JsonConvert.SerializeObject(debugOptions.StartArguments).Trim('"'); launchJson = launchJson.Replace(settings.START_ARGUMENTS, jsonStringStartArguments); var sp = new ServiceProvider((IServiceProvider)_dte); try { var dbg = sp.GetService(typeof(SVsShellDebugger)) as IVsDebugger4; if (dbg == null) { Logger.Error($"GetService did not returned SVsShellDebugger"); } VsDebugTargetInfo4[] debugTargets = new VsDebugTargetInfo4[1]; debugTargets[0].dlo = (uint)DEBUG_LAUNCH_OPERATION.DLO_CreateProcess; debugTargets[0].bstrExe = debugOptions.StartupAssemblyPath; debugTargets[0].bstrCurDir = debugOptions.OutputDirectory; debugTargets[0].bstrArg = debugOptions.StartArguments; debugTargets[0].bstrRemoteMachine = null; // debug locally //debugTargets[0].grfLaunch = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_StopDebuggingOnEnd; // When this process ends, debugging is stopped. //debugTargets[0].grfLaunch = (uint)__VSDBGLAUNCHFLAGS.DBGLAUNCH_DetachOnStop, // Detaches instead of terminating when debugging stopped. //debugTargets[0].fSendStdoutToOutputWindow = 0, //debugTargets[0].bstrExe = Path.Combine(extensionInstallationDirectory, "plink.exe"); debugTargets[0].bstrOptions = launchJson; debugTargets[0].guidLaunchDebugEngine = new Guid("{541B8A8A-6081-4506-9F0A-1CE771DEBC04}"); VsDebugTargetProcessInfo[] processInfo = new VsDebugTargetProcessInfo[debugTargets.Length]; dbg.LaunchDebugTargets4(1, debugTargets, processInfo); } catch (Exception ex) { NLogService.LogError(Logger, ex); string msg = null; var sh = sp.GetService(typeof(SVsUIShell)) as IVsUIShell; if (sh != null) { sh.GetErrorInfo(out msg); } if (!string.IsNullOrWhiteSpace(msg)) { Logger.Error(msg); } throw; } //var launchJsonFile = @"C:\TFS\launch.json"; //File.WriteAllText(launchJsonFile, launchJson); //Logger.Info($"Project {debugOptions.StartupAssemblyPath} was built successfully. Invoking remote debug command"); //var dte2 = _dte as DTE2; //dte2.ExecuteCommand("DebugAdapterHost.Launch", $"/LaunchJson:\"{launchJsonFile}\" /EngineGuid:541B8A8A-6081-4506-9F0A-1CE771DEBC04"); }
public /*override*/ int CreatePendingBreakpoint(IDebugBreakpointRequest2 pBPRequest, out IDebugPendingBreakpoint2 ppPendingBP) { NLogService.TraceEnteringMethod(); return(_engine.CreatePendingBreakpoint(pBPRequest, out ppPendingBP)); }
public /*override*/ int SetMetric(string pszMetric, object varValue) { NLogService.TraceEnteringMethod(); return(_engine.SetMetric(pszMetric, varValue)); }