Exemple #1
0
        private async Task <bool> DeployAndRunCommandOverSSHAsync(DebuggerMode debuggerMode)
        {
            // TODO error handling
            // TODO show ssh output stream
            // TODO stop monoRemoteSshDebugTask properly
            try
            {
                Logger.Info($"===== {nameof(DeployAndRunCommandOverSSHAsync)} =====");

                if (!_monoExtension.IsStartupProjectAvailable())
                {
                    Logger.Info($"No startup project/solution loaded yet.");
                    return(false);
                }

                await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                UserSettings         settings;
                DebugOptions         debugOptions;
                SshDeltaCopy.Options options;
                CreateDebugOptions(out settings, out debugOptions, out options);

                if (debuggerMode.HasFlag(DebuggerMode.DeployOverSSH))
                {
                    await _monoExtension.BuildStartupProjectAsync();

                    if (settings.UseDotnetCoreDebugger == false)
                    {
                        await _monoExtension.CreateMdbForAllDependantProjectsAsync(HostOutputWindowEx.WriteLineLaunchError);
                    }
                }

                IDebugger debugger = settings.DeployAndDebugOnLocalWindowsSystem ?
                                     (IDebugger) new LocalWindowsDebugger() :
                                     settings.UseDotnetCoreDebugger ? (IDebugger) new SSHDebuggerDotnet(options) : new SSHDebuggerMono(options);

                System.Threading.Tasks.Task <bool> monoRemoteSshDebugTask = null;

                if (debuggerMode.HasFlag(DebuggerMode.DeployOverSSH) && debuggerMode.HasFlag(DebuggerMode.DebugOverSSH))
                {
                    monoRemoteSshDebugTask = debugger.DeployRunAndDebugAsync(debugOptions, HostOutputWindowEx.WriteLaunchErrorAsync, settings.RedirectOutputOption);
                }
                else if (debuggerMode.HasFlag(DebuggerMode.DeployOverSSH))
                {
                    monoRemoteSshDebugTask = debugger.DeployAsync(debugOptions, HostOutputWindowEx.WriteLaunchErrorAsync, settings.RedirectOutputOption);
                }
                else if (debuggerMode.HasFlag(DebuggerMode.DebugOverSSH))
                {
                    monoRemoteSshDebugTask = debugger.RunAndDebugAsync(debugOptions, HostOutputWindowEx.WriteLaunchErrorAsync, settings.RedirectOutputOption);
                }

                if (debuggerMode.HasFlag(DebuggerMode.AttachProcess))
                {
                    if (settings.UseDotnetCoreDebugger)
                    {
                        var myresult = await monoRemoteSshDebugTask;
                        _monoExtension.AttachDotnetDebuggerToRunningProcess(debugOptions);
                    }
                    else
                    {
                        _monoExtension.AttachMonoDebuggerToRunningProcess(debugOptions);
                    }
                }

                if (monoRemoteSshDebugTask != null)
                {
                    var myresult = await monoRemoteSshDebugTask;
                }

                return(true);
            }
            catch (Exception ex)
            {
                await HostOutputWindowEx.WriteLineLaunchErrorAsync(ex.Message);

                Logger.Error(ex);
                MessageBox.Show(ex.Message, "VSMonoDebugger", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(false);
        }