private static void CreateDebugOptions(out UserSettings settings, out DebugOptions debugOptions, out SshDeltaCopy.Options options)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            var allDeviceSettings = UserSettingsManager.Instance.Load();

            settings = allDeviceSettings.CurrentUserSettings;

            if (settings.UseDeployPathFromProjectFileIfExists)
            {
                try
                {
                    var localProjectConfig = _monoExtension.GetProjectSettingsFromStartupProject();
                    if (localProjectConfig.HasValue)
                    {
                        if (!string.IsNullOrWhiteSpace(localProjectConfig.Value.SSHDeployPath))
                        {
                            NLogService.Logger.Info($"SSHDeployPath = {settings.SSHDeployPath} was overwritten with local *.VSMonoDebugger.config: {localProjectConfig.Value.SSHDeployPath}");
                            settings.SSHDeployPath = localProjectConfig.Value.SSHDeployPath;
                        }
                    }
                }
                catch (Exception ex)
                {
                    NLogService.Logger.Error(ex);
                }
            }

            debugOptions = _monoExtension.CreateDebugOptions(settings, true);
            options      = new SshDeltaCopy.Options()
            {
                Host                     = settings.SSHHostIP,
                Port                     = settings.SSHPort,
                Username                 = settings.SSHUsername,
                Password                 = settings.SSHPassword,
                PrivateKeyFile           = settings.SSHPrivateKeyFile,
                SourceDirectory          = debugOptions.OutputDirectory,
                DestinationDirectory     = settings.SSHDeployPath,
                RemoveOldFiles           = true,
                PrintTimings             = true,
                RemoveTempDeleteListFile = true,
            };
        }
        private static void CreateDebugOptions(out UserSettings settings, out DebugOptions debugOptions, out SshDeltaCopy.Options options)
        {
            var allDeviceSettings = UserSettingsManager.Instance.Load();

            settings     = allDeviceSettings.CurrentUserSettings;
            debugOptions = _monoExtension.CreateDebugOptions(settings, true);
            options      = new SshDeltaCopy.Options()
            {
                Host                     = settings.SSHHostIP,
                Port                     = settings.SSHPort,
                Username                 = settings.SSHUsername,
                Password                 = settings.SSHPassword,
                PrivateKeyFile           = settings.SSHPrivateKeyFile,
                SourceDirectory          = debugOptions.OutputDirectory,
                DestinationDirectory     = settings.SSHDeployPath,
                RemoveOldFiles           = true,
                PrintTimings             = true,
                RemoveTempDeleteListFile = true,
            };
        }
Beispiel #3
0
        private async Task <bool> DeployAndRunCommandOverSSH(bool deploy, bool startDebugger)
        {
            // TODO error handling
            // TODO show ssh output stream
            // TODO stop monoRemoteSshDebugTask properly
            try
            {
                if (!deploy && !startDebugger)
                {
                    return(true);
                }

                var allDeviceSettings = UserSettingsManager.Instance.Load();
                var settings          = allDeviceSettings.CurrentUserSettings;

                if (deploy)
                {
                    await _monoExtension.BuildSolutionAsync();
                }

                var debugOptions = _monoExtension.CreateDebugOptions(settings, true);

                var options = new SshDeltaCopy.Options()
                {
                    Host                     = settings.SSHHostIP,
                    Port                     = settings.SSHPort,
                    Username                 = settings.SSHUsername,
                    Password                 = settings.SSHPassword,
                    SourceDirectory          = debugOptions.OutputDirectory,
                    DestinationDirectory     = settings.SSHDeployPath,
                    RemoveOldFiles           = true,
                    PrintTimings             = true,
                    RemoveTempDeleteListFile = true,
                };

                if (deploy)
                {
                    await _monoExtension.ConvertPdb2Mdb(options.SourceDirectory, HostOutputWindowEx.WriteLineLaunchError);
                }

                System.Threading.Tasks.Task monoRemoteSshDebugTask;
                if (startDebugger)
                {
                    if (deploy)
                    {
                        monoRemoteSshDebugTask = await SSHDebugger.DeployAndDebugAsync(options, debugOptions, HostOutputWindowEx.WriteLaunchError, settings.RedirectOutputOption);
                    }
                    else
                    {
                        monoRemoteSshDebugTask = await SSHDebugger.DebugAsync(options, debugOptions, HostOutputWindowEx.WriteLaunchError, settings.RedirectOutputOption);
                    }

                    _monoExtension.AttachDebuggerToRunningProcess(debugOptions);
                }
                else
                {
                    monoRemoteSshDebugTask = await SSHDebugger.DeployAsync(options, debugOptions, HostOutputWindowEx.WriteLaunchError, settings.RedirectOutputOption);
                }

                await monoRemoteSshDebugTask;

                return(true);
            }
            catch (Exception ex)
            {
                HostOutputWindowEx.WriteLineLaunchError(ex.Message);
                NLogService.Logger.Error(ex);
                // TODO MessageBox
                MessageBox.Show(ex.Message, "MonoRemoteDebugger", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            return(false);
        }