Beispiel #1
0
        protected override void OnRun(DebuggerStartInfo startInfo)
        {
            base.OnRun(startInfo);
            UseOperationThread = true;

            var cryStartInfo = startInfo as CryEngineStartInfo;

            if (cryStartInfo == null)
            {
                throw new ArgumentException(string.Format("The value of {0} is not a valid type of '{1}'.", nameof(startInfo), typeof(CryEngineStartInfo).Name));
            }

            var listenArgs  = cryStartInfo.StartArgs as SoftDebuggerConnectArgs;
            var projectData = cryStartInfo.ProjectData;

            var launcherPath = GetLauncherPath(projectData.LauncherPath, cryStartInfo.LauncherType);

            if (!File.Exists(launcherPath))
            {
                throw new InvalidOperationException(string.Format("Did not find a valid launcher at expected location: {0}", launcherPath));
            }

            var remoteConsolePort = NetworkHelper.GetAvailablePort(4600, 4610);

            var arguments = string.Format("-project {0} -monoDebuggerPort {1} {2} -monoSuspend 1 -remoteConsolePort {3}",
                                          projectData.ProjectPath, listenArgs.DebugPort, projectData.CommandArguments, remoteConsolePort);

            var processStartInfo = new ProcessStartInfo(launcherPath, arguments)
            {
                UseShellExecute = true
            };

            _process = new Process
            {
                StartInfo = processStartInfo
            };

            _process.Exited += OnProcessExitedExternally;

            _process.Start();

            StartRemoteConsole(remoteConsolePort);
        }
        /// <summary>
        /// Called when the application is run with debugging support. Otherwise it will just launch.
        /// </summary>
        /// <param name="grfLaunch"></param>
        /// <returns></returns>
        public int DebugLaunch(uint grfLaunch)
        {
            var port = NetworkHelper.GetAvailablePort(17615, 18000);

            var startArgs = new SoftDebuggerConnectArgs("CRYENGINE", IPAddress.Loopback, port)
            {
                MaxConnectionAttempts = 10
            };

            var startInfo = new CryEngineStartInfo(startArgs, null, _baseProject, CryEngineProjectData.GetProjectData(_baseProject), _launcherType);
            var session   = new CryEngineDebuggerSession();

            IDebugLauncher debugLauncher = new CryEngineDebugLauncher();
            var            progress      = new Progress <string>();

            progress.ProgressChanged += OnProgressChanged;
            var launcher = new MonoDebuggerLauncher(progress, debugLauncher);

            launcher.StartSession(startInfo, session);

            return(VSConstants.S_OK);
        }